cancel
Showing results for 
Search instead for 
Did you mean: 

Need to change interrupt priority for USART DMA RX Circular

ATzou.1
Associate II

I've got some code working from an example for USART RX DMA Circular. I'm to the point where I can receive the UART data but I need to now use a write to a protected (by a binary semaphore) circular buffer from the interrupt context HAL_UARTEx_RxEventCallback() which can be called from interrupt context DMA TC and HT events and UART IDLE line event.

Using FreeRTOS and configured is #define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY 5 in FreeRTOSConfig.h.

When using xSemaphoreTakeFromISR and xSemaphoreGiveFromISR with a binary semaphore configured I get the following assert:

configASSERT( ucCurrentPriority >= ucMaxSysCallPriority );

Using  NVIC_SetPriority(DMA1_Channel5_IRQn, 6); so I figure that should do the trick but it's not working. When I capture the values of ucMaxSysCallPriority and ucCurrentPriority, I get values of 80 and 48 respectively. I can understand that the values are lost in translation with the NVIC groups, preemption priority and subpriority. However I did expect the NVIC_SetPriority() call above to work.

If I disable the semaphores, I can get the USART RX data into my circular buffer. I believe that I just need to get past configuration of the interrupt at a lower priority than the configMAX_SYSCALL_INTERRUPT_PRIORITY. Looking at the Groups, preemption priorities, and sub-priorities doesn't make a lot of sense to me.

Please advise.

11 REPLIES 11
ATzou.1
Associate II

Getting there. Changed all of the dma interrupts to priority 6,0 and now not getting the assert. Changed the attempt to use the semphoreFromISR to using a queue and now I'm passing the data from the interrupt to the task and input the stream into a circular buffer. As you recommended with the 'why' question ... I now see why as the sempaphoreTake from ISR never was successful. Thanks for the help on this Pavel.

You're welcome!