I am trying to implement freertos in kinetis board, I was able to start the scheduler and switch between my two tasks (with svc call ) however when entering systick handler to increment the tick and switch between the two tasks when required through the Pendsv interrupt handler the switch is not executed and then the code get stuck
Hi
Thank you for your support is working now in cortex m7 based platform
However whenever I make a reset while the tasks are running to jump again to reset handler in start-up file I get a hardfault when starting again the execution after this reset and by tracking the source of the problem I found that an unaligned access caused by STM instruction.
So I am wondering if the running tasks could cause an overwrite of same sram address causing this kind of problem?
And in general a reset while tasks are running in freertos is it safe or there are some points must be taken into consideration
7IYes it is, after reset the program counter start to fetch from address 0×4 and main start pointer of cortex m7 is loaded with value stored in address 0x00 and this is what I got however the program itself is located in sram adress 0x20000000 so therefore I was suspecting that tasks running under freertos could overwrite some sram address knowing that I am using heap_2 for allocation memory to tasks.
Other point the tasks are using the process stack pointer (psp) so I am wondering the initial value loaded to PSP when the scheduler start where it is assigned and loaded in freertos?
The problem is after reset and jumping to reset handler while tasks are running with freertos the PSP stack pointer is not initialized in start-up and PSP stack pointer is used by running tasks as recommended by arm in such cases( using thread mode and PSP stack pointer to execute freertos tasks ) but after reset , reset handler will be executed in thread mode using PSP stack pointer and not MSP and PSP will hold the last value while tasks are running
Solution switch to handler mode with MSP then initializing PSP to reset value so it could be possible restarting properly the whole program.