2015-12-03 03:15 PM
Hi, I'm new to using both STM32Cube and the FreeRTOS it provides support for, and I am trying to follow the tutorials and the FreeRTOS manuals online to create 2 separate tasks to manage the two I2C busses on our STM32L151R8T6 MCU.
Currently, only the 1st I2C task spawned ever runs, even if I put in synchro semaphores, call osThreadYield(), or change the task priorities. If I change the order of the spawns, the other I2C task runs only.I have read online that this could mean that the interrupt table is ''incorrect'', but I only have the sysTick interrupt enabled. This should be all it needs is the tick interrupt?Any ideas on what to look for would be highly appreciated. Thanks in advance!2015-12-04 07:13 AM
Hi,
try to start with simplest tasks like toggling some gpios in tasks, generally you should define thread, create it and start the kernel, the tasks should run then. When it works add more complexity to the tasks like running one i2c in one of the tasks. Also consider with more complex tasks increasing stack size for each of the tasks. Regards,2015-12-04 07:52 AM
Thanks for taking the time to reply. Yes, I already got the individual tasks running in ''single task'' mode, so I'm confident the application code is ok.
The problem is that only the first task I spawn with FreeRTOS runs. If I switch one of the other tasks to be spawned first, it runs fine, but then none of the others run. I have a feeling I am overlooking something simple in either the STM32Cube configuration, or else there is something I am supposed to configure manually that I cannot determine as yet.I'm curious if perhaps because the STM32Cube project was originally created for the IAR development system, and to create one for TrueStudio, I created an empty STM32Cube project, imported the IAR-targeted project and then changed settings to create the TrueStudio project?2015-12-04 01:59 PM
Hi,
I never use cmsis_os api, butcommonlyfreertos is need 3 IRQHandler for make scheduler run, vPortSVCHandler (SVC_Handler) - for switch from main to first task. (Somearchitecture not need it.) xPortSysTickHandler(SysTick_Handler) - for count tick, stimulatethePendSV_Handler and etc. xPortPendSVHandler (PendSV_Handler) - for do the context switch. you can call xPortSysTickHandlerfunction inSysTick_Handler like below:extern void xPortSysTickHandler( void );
void SysTick_Handler(void)
{
HAL_IncTick();
xPortSysTickHandler();
}
but you must putvPortSVCHandler andxPortPendSVHandlerfunction ininterrupt vector table.
Usually,I used to define the macro in FreeRTOSConfig.h like below.
#define vPortSVCHandler SVC_Handler
#define xPortPendSVHandler PendSV_Handler
there macro are makevPortSVCHandler and xPortPendSVHandler in port.c (portasm.s in IAR) to beSVC_Handler andPendSV_Handler. Then comment out theSVC_Handler andPendSV_Handler function in stm32xxxx_it.c
in debug mode, when first task is running. try to place breakpoint in SysTick_Handler andxPortPendSVHandler for make sure that xPortPendSVHandler is called after SysTick timer fire.
SVC_Handler,SysTick_Handler andPendSV_Handler are automaticallyenabled when xTaskStartScheduler is called.
Sorry for my bad communication, I'm not good in English.
2015-12-04 03:18 PM
I just wanted to let everyone following this thread that I discovered the real reason my subsequent tasks were not running.
The problem turned out that the subsequent tasks were failing the spawn process in the first place due to the stack request of the subsequent tasks being larger than remaining heap size. Once I adjusted the stack sizes accordingly, my project is now nicely task-switching managing button presses and LEDs properly.