This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

FreeRTOS + ble_app_uart_c +SPI(for external sensor) = instability

I used nRF52832 , SDK 15.0 ,S132,FreeRTOS 10(From "ble_app_hrs_freertos")。

My work needs to be realized three functions:

(1) From "ble_uart_c" method receive another BLE send data;

(2) Use the FreeRTOS resolved the multi-task;

(3) From SPI to receive the external sensor data ( 200Hz ,by interrupt).

First I transplanted the FreeRTOS from   "ble_app_hrs_freertos" sample, and used to  "ble_app_uart_c " sample , it worked well, it's ok.

Second  I added the external sensor interrupt and event-Handle, and it also work well;

Finally ,I put them together , the problem is , the "ble_uart_c"  will connects, disconnects, and reconnects frequently, the connected time is more than ten seconds.

I think maybe is the Priority problem,but I set the "#define configMAX_PRIORITIES    ( 5 )" , and set the "ble_uart_c"  4;  and set the "#define taskPRIO_RxData 3 "(receive the sensor data function task), and it's not work, I am very confused and worried.

Can you help me ,thanks very much ,I will be waiting!

// the INT of Sensor
static void vINTHandler(nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t actio)
{
    BaseType_t xHigherPriorityTaskWoken = pdFALSE;
    G_Counter++;
    xTaskNotifyFromISR(xTaskHandle_RxData_MPU9255,     
                       G_Counter,               
                       eSetValueWithOverwrite,
                        &xHigherPriorityTaskWoken);
     
     portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
}

//the task of Rx Sensor data
static void vTask_RxData_MPU9255(void *pvParameters)
{

    uint8_t error_temp = 0;
    while(1)
    {

        xTaskNotifyWait(0x00000000,     
                        0xFFFFFFFF,     
                        NULL,                 
                        portMAX_DELAY);       
        
        memcpy(G_Data+6,&G_MicroSecond,2);
        memcpy(G_Data+2,&G_WeekSecond,4);
        memcpy(G_Data+8,&G_Counter,4);   
    }
}

They both work very well separately, but when they work together they have problems, they seem to interfere with each other. 

Parents Reply Children
Related