2021-08-20 04:47 PM
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.
2021-08-24 04:53 PM
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.
2021-08-24 05:17 PM
You're welcome!