This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

LPSTK-CC1352R: cc1352r1 LPSTK and BMI160 module integration with SAIL

Part Number: LPSTK-CC1352R
Other Parts Discussed in Thread: SYSCONFIG

Hello,

I’m trying to stream out BMI160 data through BLE using the CC1352r1 LPSK module.

My starting point is the Simple Serial Socket example available here (https://github.com/ti-simplelink/ble_examples/tree/simplelink_cc13x2_26x2_sdk-4.10). I’m using the client (central) project.

I’m able to compile the example and it works very well.

 

Now, the idea is to add the BMI160 (with BMM150) module. I used the SAIL “bmi160i2c” example and then I implemented the POSIX procedure similar to the one proposed here https://dev.ti.com/tirex/content/simplelink_academy_cc2640r2sdk_2_30_02_00/modules/blestack/ble_posix/ble_01_posix.html to have both tasks (BLE and BMI160) running on the same CC1352 chip. I also configured i2c and GPIO interrupt pins in sysconfig to get sensor data.

As a result, also this task works fine, and I’m able to display acc, gyr and mag on my terminal (teraterm).

Unfortunately, when I run BLE and BMI160 tasks together (startup selection is a main.c level), the system works well (BLE connected, and BMI data Displayed) for a random time of about 1 minute. After this time, the BLE continue to work, but the BMI task hangs and stops updating the terminal display. I reset the system, but the result is ever the same: BLE and BMI tasks work well separately, but not together. Note that to avoid conflict between UART and Display I also assigned UART0 to Display, and UART1 to BLE task.

With the idea to solve the problem, I reduced the priority of BLE task, and improved the priorities of both “display” and “bmi interrupt” tasks from 2 to 1 in the “bmi160_support.c” file, as well as I reduced the “bmi interrupt” TASK size. However, after several tests with different priorities and task sizes the result is ever the same!

At the moment both tasks are not exchanging data, they are just the two TI examples merged together by using the POSIX procedure.

SDK version is 4.40_04_04 ( I also tested other versions) and the compiler version is 20.02.04, but I also tested other versions (like 18.xx.xx) without any difference in the result.

Which could the problem in your opinion?

this is my working thread and the related _create function for BMI160:

______________________________________________________

#includes........

*  ======== myThread ========
*/
void *myThread(void *arg0) {
  /* We will fill this in later */
    /* Call driver init functions */
     GPIO_init();
     I2C_init();



     /* Open the HOST display for output */
     display = Display_open(Display_Type_ANY, NULL);
     if (display == NULL) {
         while (1);
     }
     Display_print0(display, 13, 0, "Starting the i2cbmi160 sensor example...\n\n");

     I2C_Params_init(&i2cParams);
     i2cParams.bitRate = I2C_400kHz;
     i2cParams.transferMode = I2C_MODE_BLOCKING;
     i2cParams.transferCallbackFxn = NULL;
     i2c = I2C_open(CONFIG_I2C_BMI, &i2cParams);
     if (i2c == NULL) {
         Display_print0(display, 14, 0, "Error Initializing I2C\n");
     }
     else {
         Display_print0(display, 14, 0, "I2C Initialized!\n");
     }

     bmi160_initialize_sensor(i2c);

     return (0);
}

/*
*  ======== myThread_create ========
*/
void myThread_create(void) {
   pthread_t           thread;
  pthread_attr_t      pAttrs;
  struct sched_param  priParam;
  int                 retc;

  /* Call driver init functions */
 // Board_initGeneral();

  /* Initialize the attributes structure with default values */
  pthread_attr_init(&pAttrs);

  /* Set priority, detach state, and stack size attributes */
  priParam.sched_priority = 1;
  retc = pthread_attr_setschedparam(&pAttrs, &priParam);
  retc |= pthread_attr_setdetachstate(&pAttrs, PTHREAD_CREATE_DETACHED);
  retc |= pthread_attr_setstacksize(&pAttrs, THREADSTACKSIZE);
  if (retc != 0) {
      /* failed to set attributes */
      while (1) {}
  }

  retc = pthread_create(&thread, &pAttrs, myThread, NULL);
  if (retc != 0) {
      /* pthread_create() failed */
      while (1);
  }
}

Thank you very much

Best Regards

Riccardo