Hello,
I know it is a recurrent topic but after I read all a could find about this, I still have a problem using interrupts in combination with FreeRTOS.
I’m using libopencm3. On my board I can run the libopencm3 USB stack in interrupt mode without problem. But, if I run a FreeRTOS task, it mess up things (I get my device always connect/disconnect). I didn’t look at the root cause of this connect/disconnect problem. However I suspect the usbd_poll function (called in the USB ISR) to be preempted. My ISR is as simple as this:
void otgfsisr(void)
{
usbdpoll(mscdev);
}
And my task (I know, there is no vTaskDelay):
static portTASK_FUNCTION(vLEDFlashTask, pvParameters)
{
(void) pvParameters;
int i = 0;
for(;;) {
// It waits for TX reg empty then send the char
usartsendblocking(USART1, ‘A’);
gpio_toggle(GPIOG, GPIO6);
}
}
I did setup all the priority bits as pre-emption priority:
// Same as NVICPriorityGroupConfig( NVICPriorityGroup4 )
scbsetprioritygrouping(SCBAIRCRPRIGROUPGROUP16NOSUB);
My ISR priority is 1:
nvicsetpriority(NVICOTGFS_IRQ, 1);
I also tried to change the system handler priority for systick, svcall and pendsv (as for what I understood are priority ‘0’ by default):
SCBSHPR(SCBSHPRPRI11SVCALL) = 12;
SCBSHPR(SCBSHPRPRI14PENDSV) = 13;
SCBSHPR(SCBSHPRPRI15_SYSTICK) = 14;
However if I remove the usart
sendblocking call in the task, it works as expected. Anyone as a clue ?
Thanks in advance,
Franck.