FreeRTOS & EA LPC3131

darkvegetable wrote on Sunday, March 08, 2009:


I have _just_ got FreeRTOS V5.1.2 running on my EA LPC3131 devboard, it’s a bit of a hack but the vLEDFlashTask task now runs and the GPIO_BOOT2 LED blinks!!!

I noticed that it does not run with the configUSE_PREEMPTION flag set to ‘1’. The code crashes somewhere in/after the first timer interrupt with an Abort Exception but LR_ABT is garbage (actually, some addy in uninitialized RAM) so I’m lost in Hyperspace :frowning: Has anyone else seen this behavior on ARM9?

rtel wrote on Tuesday, March 10, 2009:

Check that the startup code does not have an unterminated comment in it that prevents the data abort stack being setup correctly.

msr   CPSR_c, #MODE_UND|I_BIT|F_BIT /* Undefined Instruction Mode

is the offending line.  This has just been fixed in SVN.

Also, are you vectoring directly to the peripheral handler, or through a common IRQ entry point.  This effects the code required.

Have you also checked for stack overflows?

Does the tick interrupt work ok when you are using co-operative mode?  When using pre-emptive mode the entry/exit from the IRQ needs to be different in order to save and restore the task context.  Check the examples for other ARM7/9 GCC demos for how this is done.


darkvegetable wrote on Tuesday, March 10, 2009:

The LPC313x uses Vectored interrupts, so I have one IRQ (and one FIQ) handler that checks a reg for the Idx of the interrupt that fired. The IRQ and FIQ handlers are "naked" but the specific handlers are not.

Anyway, turns out I was calling portSAVE_CONTEXT/portRESTORE_CONTEXT in the IRQ handler AND in vPreemptiveTick() - the vNonPreemptiveTick() function does not have this. Removing the portSAVE_CONTEXT/portRESTORE_CONTEXT from the vPreemptiveTick() function solves the problem & the pre-emptive version works now

Thanks for the tips.

jppoulin wrote on Tuesday, April 21, 2009:


I also have this EA LPC3131 board and am actively developing on it.

I would be interested in contributing to refining this port of FreeRTOS to this platform.

Are you looking for a contributor?

   Kind regards,

   Jean-Pierre Poulin

typeiii wrote on Sunday, March 07, 2010:

I’m starting on an lpc3131 port also. have it ticking and “maybe” context switching - just starting to run tests. would like to see how you did yours. any chance we could share thought/code?

typeiii wrote on Tuesday, March 09, 2010:

(hate to whine in blogs, but i could use a clue on this one)
Anybody have any luck using the nxp lpc313x_***_driver.c files? I am thinking it would be better to write new ones, since a timer tick and a context switch seem to be the only “system” functions needed. Timer tick is simple but i have a question regarding use mode vs service mode. I assume that “you guys” are running in service mode, since the examples i have looked at do things like enable/disable interrupts in the RTOS code. Otherwise i think i would have to wrap the enable/disable up in a SWI call.
Are you using IAR, GCC or Keil toolchains? I am using Keil MDK.
Thanks for any comments,