bertino wrote on Thursday, February 27, 2014:
Hello,
I’m moving my first steps with FREERtos 7.6.0 running on an STM32L1 (cortex M3 based).
In my basic application i have two tasks, one blinking leds and the other one sending alphabet
charachters to the USB virtual com port. Everything goes well only if I do not add a 500 millisecond task delay after each charachter print in the last of the two tasks. Actually it looks like if adding vTaskDelay(…) in the aforementioned task, stops USB interrupts. The USB library is the standard one delivered with ST micros and does not use FreeRTOS APIs. Here the code snippets for more details, starting from the task from where the issue comes out :
static void MTask( void *pvParameters )
{
uint8_t k = 0;
for( ;; ){
putchar(65 + k); /* sends out a char to the USB port */
k=(k+1)%90;
vTaskDelay( 500 / portTICK_RATE_MS ); /* chars go out to USB only if I delete this line!! */
}
}
static void LedTask( void *pvParameters )
{
static uint8_t toggle = 0;
signed short temp;
for( ;; ){
if (toggle) {
GPIO_LOW(GPIOC,GPIO_Pin_1); //ORANGE lED
GPIO_LOW(GPIOC,GPIO_Pin_4); //BLUE LED
GPIO_HIGH(GPIOD,GPIO_Pin_2); //RED lED
} else {
GPIO_HIGH(GPIOC,GPIO_Pin_1);
GPIO_HIGH(GPIOC,GPIO_Pin_4);
GPIO_LOW(GPIOD,GPIO_Pin_2);
}
toggle = 1 - toggle;
vTaskDelay( 250 / portTICK_RATE_MS );
}
}
…in main I have:
int main(void)
{
Main_HW_Init();
xTaskCreate( MTask, ( signed char * ) "MainTask", (configMINIMAL_STACK_SIZE * 2), NULL, M_TASK_PRIORITY, &xMemsTaskHandle);
xTaskCreate( LedTask, ( signed char * ) "LED", (configMINIMAL_STACK_SIZE * 2), NULL, Led_TASK_PRIORITY, &xLedTaskHandle);
/* Start the scheduler. */
vTaskStartScheduler();
/* we should never get here */
for( ;; );
}
The two tasks run with same priority, within my settings I have :
#define configLIBRARY_LOWEST_INTERRUPT_PRIORITY 10
#define configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY 5
#define configKERNEL_INTERRUPT_PRIORITY ( configLIBRARY_LOWEST_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )
#define configMAX_SYSCALL_INTERRUPT_PRIORITY ( configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY << (8 - configPRIO_BITS) )
Cortex M3 priority group set to 4 (NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4)
Regarding USB priorities I have tested 13,7,1 ranging from lower to higher, really expecting 1 was high enough priority on cortex M3 but didn’t work.
…hoping I didn’t forget other significant details… do you see anything that is so evidently wrong in what I’m doing?
Thank you in advance,
Adalberto