(21569) FreeRTOS debugging issues, and synchronization of interrupts and tasks

Hello, I have some troubles when writing 21569 driver using freeRTOS.

I use CCES 2.9.2, 2.9.4, 2.10.0 version. I use ADI freeRTOS development program in the integrated development environment. During the debugging process, sometimes the development environment cannot locate the PC. This is Exist in all three versions.

In this environment, I used adi bsp driver and service for audio driver development, and I referenced freeRTOS official routines. Use binary semaphores to synchronize interrupts and tasks. Similar to the program below.

In the DMA interrupt, the semaphore is given.

static void adc_isr(int event, void* paramters) {

    BaseType_t xHigherPriorityTaskWoken = pdFALSE;
    BaseType_t res = pdFALSE;

    res = xSemaphoreGiveFromISR(xbinary_aud_ready, &xHigherPriorityTaskWoken);

    if ( res != pdTRUE ) {
        /* Error handling */
    }

    if ( xHigherPriorityTaskWoken == pdTRUE )
    {
        vTaskSwitchContext();
    }

}

In audio processing tasks, try to block the acquisition of semaphore.


void vtask_audio_processor( void *pvParameters ) {

    (void)pvParameters;

    /* Initialize the audio codec */
    sys_codec_init();

    for (;;) {

        BaseType_t res = pdFALSE;

        /* Wait for the audio transmission complete signal */
        res = xSemaphoreTake(xbinary_aud_ready, portMAX_DELAY);

        /* Process Audio Signal */

    }

}

The semaphore has been properly initialized during the task creation process, and the audio codec, serial port, signal routing, etc. have also been properly initialized.

But the above code did not execute as expected. With the same code, when I use another periodic task to call xSemaphoreGive to give a semaphore, the audio processing task can be executed as expected.

Does ADI have freeRTOS routines for synchronization between tasks and interrupts?

  • static void adc_isr(int event, void* paramters) {

        BaseType_t xHigherPriorityTaskWoken = pdFALSE;

        xSemaphoreGiveFromISR(xbinary_aud_ready, &xHigherPriorityTaskWoken);
        portYIELD_FROM_ISR(xHigherPriorityTaskWoken);

    }

    I found the problem. After releasing the semaphore, when checking whether a higher priority task is suspended, portYIELD_FROM_ISR should be used to actively release the CPU.