Pic32mz issues with free RTOS

I am facing problems while using free RTOS with PIC32MZ2048EFM100… it works well and then all of a sudden when the code is modified it just fails to work although there is no syntax or logical error in the project… for example when a variable is added it stops working and gives refill exception and once a dummy variable is added along with it starts working… it takes a lot of time to code with these issues… has anyone else faced these issues? Has anyone resolved such issue kindly help… thankyou

sounds like a stack problem. Either you write over your stack (size too small), or you try to pass a pointer pointing into a task stack to another task , or you write past the boundary of a local array, or… impossible to say without seeing code. Make a minimal code example showing the problem and post the code here, or on github.

This might be a long shot, but maybe give this suggestion a try?

I would be very curious if this helps resolve the problem you are seeing.

Definitely for PIC32 you will want to add this to your FreeRTOS config file:
#define configLIST_VOLATILE volatile

Other things you have to consider:
1: Timer1 is used as the tick timer. make sure to enable its clock.
2: Using the base examples, make sure to divide the peripheral clocks to 40MHz as this is what the sample code expects.
3: Disable the shadow registers feature
4: If you have any floating point operation in the task, you have to call portTASK_USES_FLOATING_POINT() at the beginning of your task so the floating point registers are saved on context switch.

I have narrowed down the issues and it looks like an alignment issue when I use align attribute it starts working… but I want a fix so that I don’t have align them manually is there any option which I can set and it can automatically align the array or structures, etc.

Another thing which I have noticed is that when data memory is multiple of 16 it works fine but other than that it stops working…

I have tried to explore manual memory allocation of pickit but I am unable to find a way to sort this issue.

Any help will be appreciated

Where are you adding the alignment attribute?

Do you mean the size of the data section in the linker script or something else?

I use attribute align() with variables

Which variables do you add this attribute to? Can you share code?