I have created a basic task just to blink an LED. After debugging, it seems like the task was entered but it did not run further.
I am trying to add FreeRTOS manually (without any config or code generator) in STM32F407VET6 board. IDE used is STM32Cube.
#TC was printed successfully.
I tried to print a message “#A” inside the task but only # was received on the Serial Terminal. I am not able to figure out where this is failing.
Below is a snapshot of FreeRTOSConfig.h
#if defined(__ICCARM__) || defined(__CC_ARM) || defined(__GNUC__)
#include <stdint.h>
extern uint32_t SystemCoreClock;
#endif
#ifndef CMSIS_device_header
#define CMSIS_device_header "stm32f4xx.h"
#endif /* CMSIS_device_header */
#define configENABLE_FPU 0
#define configENABLE_MPU 0
#define configUSE_PREEMPTION 1
#define configSUPPORT_STATIC_ALLOCATION 0
#define configSUPPORT_DYNAMIC_ALLOCATION 1
#define configUSE_IDLE_HOOK 0
#define configUSE_TICK_HOOK 0
#define configCPU_CLOCK_HZ ( 8000000 )
#define configTICK_RATE_HZ ((TickType_t)1000)
#define configMAX_PRIORITIES ( 56 )
#define configMINIMAL_STACK_SIZE ((uint16_t)128)
#define configTOTAL_HEAP_SIZE ((size_t)15360)
#define configMAX_TASK_NAME_LEN ( 16 )
#define configUSE_TRACE_FACILITY 1
#define configUSE_16_BIT_TICKS 0
#define configUSE_MUTEXES 1
#define configQUEUE_REGISTRY_SIZE 8
#define configUSE_RECURSIVE_MUTEXES 1
#define configUSE_COUNTING_SEMAPHORES 1
#define configUSE_PORT_OPTIMISED_TASK_SELECTION 0
/* USER CODE BEGIN MESSAGE_BUFFER_LENGTH_TYPE */
/* Defaults to size_t for backward compatibility, but can be changed
if lengths will always be less than the number of bytes in a size_t. */
#define configMESSAGE_BUFFER_LENGTH_TYPE size_t
These two are the UART functions if needed for reference
It’s maybe not the problem but I wouldn’t recommend to use configMINIMAL_STACK_SIZE for your application tasks(s). Simply because usually it’s just not enough. Better start with a larger size und tailor it later.
Also you should define configASSERT , enable stack overflow checking for development/debugging. That’s very helpful.
Is the FreeRTOS SysTick working as expected resp. is TaskHeartBeat toggling the LEDs with the right frequency when commenting out UART_TxSTRING ?
Thank you for the response.
Even if i remove UART_TxString(), the result is same. The LEDs just toggle once. I even used 500 instead of configMINIMAL_STACK_SIZE but the issue is still there.
Then it seems the SysTick isn’t ticking.
In case you use the defaults:
in FreeRTOSConfig.h
/* Definitions that map the FreeRTOS port interrupt handlers to their CMSIS standard names. */
#define vPortSVCHandler SVC_Handler
#define xPortPendSVHandler PendSV_Handler
#define xPortSysTickHandler SysTick_Handler
and verify the corresponding entries in your exception table:
Do you have a debugger attached ? Then you could easily check, that the SysTick_Handler or alternatively the FreeRTOS function xTaskIncrementTick is invoked periodically after starting the scheduler.
I am currently using the Chinese ST-Link V2. It doesn’t support debugging as of now. Might need to tweak its hardware to get the debugger running.
Also I figured out that configCPU_CLOCK_HZ should be 168MHz instead of 8MHz (as 8MHz is the Xtal Freq. which is then fed to the PLL)
Where can I find that exception table?
The broken clock config might be also the reason for a (very) wrong tick rate.
The exception table is part of the sources. Just grep for … SysTick_Handler or Reset_Handler and I’m sure you’ll find it.
ST-Link V2 should be fine. Better try to get the debugger working. Believe me, you’ll really need it sooner or later
The vector table was found in the startup file. But i couldn’t understand how it should be. I compared the startup file with the one used in a working FreeRTOS project, not much difference was found.
Looks good - it’s standard. The check was only to be sure that e.g. the symbol / ISR function SysTick_Handler is exactly the same in the table and in the code.
Using a debugger and breakpoint in this function and check that it’s hit is more easy to verify that the SysTick works
So does your FreeRTOSConfig.h contain the Handler defines mentioned before and is the CLOCK config fixed ? Then it should blink
The clock configuration for the MCu was already proper. It has worked always. Even after changing the configCPU_CLOCK_HZ, it didn’t work. The name of handlers are also there in Config file as they should be.
So as a quicker solution, I had to create a new project with FreeRTOS using the IDE’s code generator (as it always gives working code). Then I manually added my own code elements one by one. Now it is working perfectly as if I made an empty project.
Though if this issue happens again in future, I might need to get into it deeper and also get the debugger running.
Thank you so much for your support.