Lattice Mico32

Hi,
I would like to use the community port of FreeRTOS on a Lattice Mico32. I downloaded the files available at /fr-content-src/uploads/2019/07/index.html?http://interactive.freertos.org/forums/104358-lattice. I tried to buid this with the version of FreeRTOS 4.7.0 (what it was created for). There are some missing include files :
#include “system_conf.h” #include “Timer.h” #include “GPIO.h” I suppose this is some lattice specific headers files, but can’t find them anywhere. Does anyone have any pointers here ? Thanks in advance Jon

Lattice Mico32

Yes I think you must be right, there are not FreeRTOS files. Could it be that the version of the Lattice tools has changed since the port was posted?

Lattice Mico32

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> #define TIMER_CONTROL_INT_BIT_MASK   1 << 0
#define TIMER_CONTROL_CONT_BIT_MASK  1 << 1
#define TIMER_CONTROL_START_BIT_MASK 1 << 2
#define TIMER_CONTROL_STOP_BIT_MASK  1 << 3 #define TIMER_BASE_ADDRESS 0xA0000600 // This is the timer address for my configuration, it should be changed typedef struct {
  volatile uint32_t Status;
  volatile uint32_t Control;
  volatile uint32_t Period;
  volatile uint32_t Snapshot;
} Timer_t ; #endif 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();

Lattice Mico32

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 ..?

Lattice Mico32

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;