FreeRTOS and CMSIS for LPCEXPRESSO

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

FreeRTOS and CMSIS for LPCEXPRESSO

2,284 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by fjrg76 on Fri Oct 21 23:08:21 MST 2011
Hi

I'm writing an application where I want to use FreeRTOS for the LPC1114 (and LPC1788), but in the example "Freertos_lpc11xx" from NXP site, it seems that the RTOS port doesn't use the CMSIS api. I need it because I must port some parts of my code, from the LPC1114 to the LPC1788 sooner or later, and I would like the process to be painless.

In the example there is a file called "small_gpio.h" where only GPIO is implemented. This is ok for toggling the led on-board (and for the UART with the semi-host Code-Red's library); however, it is not useful for bigger projects in which one wants to use timers, IIC, SPI, etc.

Does anyone can lead my towards some useful information? May be an app note, a FreeRTOS bigger example, etc.

Thank you in advanced.
0 Kudos
Reply
11 Replies

2,148 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by fjrg76 on Mon Nov 14 23:47:29 MST 2011

Quote: DaveNadler
[FONT=Arial]
Careful, that code is for a Cortex M3;  FreeRTOS port would not be appropriate for M0...[/FONT]



Hi Dave

I would have listened to you when you gave me the advise, but I guess I needed to see it by myself. I changed the files as you told me to do so, and now my application is not crashing anymore.

It's worth to mention that applying the changes is not straight forward, so here are the steps I followed, just in case someone else faces the same troubles:

1. Download and override the two M0 FreeRTOS port files (these files are supplied by Dave, look for them below this conversation) that came with the original LPCXpresso-FreeRTOS example.

I suggested Dave to make patch files instead of handling these two files. We must wait, because he is the one that is going to tell us whether that is possible or not.

2. Download the CMSIS 2.0 zip package and install it (inside LPCXpresso).

3. Delete the CMSIS 1.3 (LPCXpresso).

4. Find and change all the CMSIS 1.3 references for CMSIS 2.0 (includes, libraries, paths, etc).

5. Go to Project->Properties->Project references and uncheck the CMSIS 1.3 reference, and check the CMSIS 2.0 reference.

Those steps are very general (kind of vague I should admit) but after follow them you will be able to compile again your application without re-writing any code.

Any comments are welcomed. Thank you Dave!!

Kind regards


[COLOR=Red][B]UPDATE: I built a project that saves you all these steps, in case you want to use this free-bug release. If someone is interested, it can be downloaded from this link:

http://knowledgebase.nxp.com/showthread.php?t=2601[/B][/COLOR]
0 Kudos
Reply

2,148 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by fjrg76 on Fri Nov 04 12:34:47 MST 2011

Quote: DaveNadler
[FONT=Arial]That version was incompletely ported from M3. It has serious bugs (like using registers not implemented by the M0 CPU), and it will crash under load. Guess how I know :mad:
For details read the thread linked below.
For safer operation use the version I posted.
Hope that helps,
Best Regards, Dave[/FONT]



Thank you Dave, I'll take very seriously your comments, 'cause I wouldn't like to see how my system crashes, and having no idea why.
0 Kudos
Reply

2,148 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by fjrg76 on Thu Nov 03 15:03:54 MST 2011

Quote: fjrg76
Hi

The FreeRTOS example that came with LPCXpresso is working (almost) nice with two tasks, and semihosting for serial comms (before I build the RS232 level converter). One task keeps real time, whilst other one prints out the system time every one second. I can see the system time in the integrated console, however, it doesn't update each second, but two seconds (system ticks calibration is ok, one second is one second). I'm thinking that semihosting uses a buffer or so, and that could be the reason why the system time is not updating as expected.

And after all, I'll need the RS232 level converter for real applications, so I built it. But now LPC UART is not working (with Redlib=NONE, no more semihosting). I followed the UART's device driver that also comes with the LPCXpresso.

What I'm doing now is to forget (for a while) the RTOS and tasks and friends, so I can focus in making the UART to work.

Any help is welcome (examples,tips, etc).

Kind regards



Answering myself, my theory was correct. Red Code semihost library uses a kind of internal buffer that needs to be filled before the bytes leave out, that's way it updates every two seconds instead the one second programmed.

I've built the RS232 level converter, and I stopped using semishosting, so now I'm seeing how my system-time is updating every one second, as expected, in a PC serial terminal. Even, it was integrated into the kernel as a task (I first tried to make the UART to work with no kernel at all) and it's working great. I'm happy :)
0 Kudos
Reply

2,148 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by fjrg76 on Thu Nov 03 14:57:10 MST 2011

Quote: inma
I would like to ask whether it is possible to use free RTOS-es (for example FreeRTOS) with the free version of LPCXpresso IDE. I'm asking this because of the 128k code size limitation. I haven't used any embedded operating systems so far, but I heard that the can easily be several kilobytes in the flash.

How complex RTOS application is 128k flash enough for?



Hi

FreeRTOS is pretty small, so it can acommodate in less than 10KB. The example that comes with LPCXpresso uses 8KB as out-of-the-box, and some says it will run with less than 2KB (I haven't had time to drop out things I don't need so I can measure that correctly). The main concern is about RAM. Each task block uses (for its own existence) some bytes, and each process itself uses as much as RAM as required (for stack purposes). Also, services like semaphores and queues uses some amount of RAM. But  almost all services and stack RAM are configurable, so you can fine them out to fit your application and processor.

Back in time to your question, the answer is yes, you can use FreeRTOS with the free LPCXpresso edition, and run it even in the LPC1114 processor (32KB flash, 8KB RAM), which I'm doing right now.

Another popular RTOS is uC-OS II kernel. It's is small enough, but you need to pay for commercial applications. There are other RTOS around, but FreeRTOS is well supported, and have a lot of ports, and it seems to be the RTOS de-facto for NXP Cortex processors.

Tip: Before you try any RTOS, you should get used to some terminology that will be useful when you start working with:

- task (or process)
- kernel
- scheduler
- pre-emptive vs no pre-emptive, round-robin scheduling
- interrupts
- services (semaphore, queue, etc.)
- real-time
- porting the kernel
- etc.

Hope this information is useful :)
0 Kudos
Reply

2,148 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by inma on Thu Nov 03 13:38:57 MST 2011
I would like to ask whether it is possible to use free RTOS-es (for example FreeRTOS) with the free version of LPCXpresso IDE. I'm asking this because of the 128k code size limitation. I haven't used any embedded operating systems so far, but I heard that the can easily be several kilobytes in the flash.

How complex RTOS application is 128k flash enough for?
0 Kudos
Reply

2,148 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by fjrg76 on Wed Nov 02 22:25:27 MST 2011
Hi

The FreeRTOS example that came with LPCXpresso is working (almost) nice with two tasks, and semihosting for serial comms (before I build the RS232 level converter). One task keeps real time, whilst other one prints out the system time every one second. I can see the system time in the integrated console, however, it doesn't update each second, but two seconds (system ticks calibration is ok, one second is one second). I'm thinking that semihosting uses a buffer or so, and that could be the reason why the system time is not updating as expected.

And after all, I'll need the RS232 level converter for real applications, so I built it. But now LPC UART is not working (with Redlib=NONE, no more semihosting). I followed the UART's device driver that also comes with the LPCXpresso.

What I'm doing now is to forget (for a while) the RTOS and tasks and friends, so I can focus in making the UART to work.

Any help is welcome (examples,tips, etc).

Kind regards
0 Kudos
Reply

2,148 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by DaveNadler on Tue Oct 25 03:54:41 MST 2011

Quote: fjrg76
The FreeRTOS port I'm using it is the one supplied from NXP and it is intended for the M0 family. At the moment it's working great.


[FONT=Arial]That version was incompletely ported from M3. It has serious bugs (like using registers not implemented by the M0 CPU), and it will crash under load. Guess how I know :mad:
For details read the thread linked below.
For safer operation use the version I posted.
Hope that helps,
Best Regards, Dave[/FONT]
0 Kudos
Reply

2,148 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by fjrg76 on Mon Oct 24 21:47:46 MST 2011

Quote: DaveNadler
[FONT=Arial]
Careful, that code is for a Cortex M3;  FreeRTOS port would not be appropriate for M0...[/FONT]



Thank you for the advice

But I'm not using it out of the box. Fortunately peripherals are quiet similar among families, and that code works well as a point of starting, instead of writing drivers from scratch. (And of course, one needs to have the LPC1114 user manual right away.)

The FreeRTOS port I'm using it is the one supplied from NXP and it is intended for the M0 family. At the moment it's working great.
0 Kudos
Reply

2,148 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by DaveNadler on Sun Oct 23 13:52:14 MST 2011

Quote: fjrg76
I also found this other port which I'm studying right now:
http://code.google.com/p/lpc1343codebase/downloads/list


[FONT=Arial]
Careful, that code is for a Cortex M3;  FreeRTOS port would not be appropriate for M0...[/FONT]
0 Kudos
Reply

2,148 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by fjrg76 on Sun Oct 23 13:46:25 MST 2011
Hi Dave

I'll take it a look immediatly. I also found this other port which I'm studying right now:

http://code.google.com/p/lpc1343codebase/downloads/list

This is from fellow in Europe, and I don't know yet whether it is a distro for a board of his own, or he wants it to become a kind of standard.

Thank you!!
0 Kudos
Reply

2,147 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by DaveNadler on Sat Oct 22 11:09:51 MST 2011
[FONT=Arial]For FreeRTOS, start with version 7.01 from FreeRTOS,
and overlay the attached. This version does use CMSIS 2
and fixes [U][B]many[/B][/U] bugs in the example distribution you
received. This port is for Cortex M0 only. I am using it
on LPC11C14.

For details on this (unofficial) FreeeRTOS port, see:
http://www.freertos.org/index.html?http://interactive.freertos.org/entries/20295001

The "drivers" subdirectory in your LPCXpresso distribution
contains a number of drivers for assorted peripherals. Be
warned that these are very simple; you may need to write
something more sophisticated for your application but
these are excellent starting points.

Hope this is helpful,
Best Regards, Dave[/FONT]
0 Kudos
Reply