So I got it to compile using the following Timer.h (writtten after reading the lattice mico32 timer spec) #ifndef TIMER_H #define TIMER_H #include <stdint.h>
However, context switching does not occur. I can see that the timer interrupt handler is called, I can see that the systick is incrementing, but it doesn’t change context. Could someone explain what normally happens when the ISR handlers executes the following functions ?
vTaskIncrementTick();
vTaskSwitchContext();
This is what when I dump the values that are logged by the trace utility :
…
TickCount :14 previous :1
TickCount :15 previous :0
TickCount :16 previous :1
TickCount :17 previous :0
TickCount :18 previous :1
…
It looks like both my tasks are beeing scheduled
However, I am sure that when I launch two tasks, only the code from the last created task is executed. The code from the other task is not executed.
Does anyone have any pointers …?
Ok, I had not seen the low level interrupt routine vPortInterruptHandler that saves and restores contexts… I was calling the high level IRQ directly. Now that I changed that, it works like a charm !
I had to add one line to port.c though, but maybe that’s because i’m running a simulated timer, not the real timer from lattice.
Here’s the line :
+ pTimer->Period = configCPU_CLOCK_HZ / configTICK_RATE_HZ ;
pTimer->Control = TIMER_CONTROL_START_BIT_MASK | TIMER_CONTROL_INT_BIT_MASK | TIMER_CONTROL_CONT_BIT_MASK;