Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training


LPC2368 with Keil tools?

Posted by Richard on May 29, 2007
[Moved from private email. Please use the forum for free support.]


I'd like to have info about port of FreeRTOS to ARM7 (possibly LPC2368 / MCB2300 demo board) using Keil MDK (uVision).

I also have seen on FreeRTOS a port involving uIP based on Rowley CrossStudio. Is it possible to have uIP ported on Keil too?

RE: LPC2368 with Keil tools?

Posted by Richard on May 29, 2007
Currently the FreeRTOS.org download does not contain any ports for the Keil IDE with the ARM compiler, although there are ports for the Keil IDE with the old (and now defunct) Keil compiler.

I do plan to include support for the new Keil/ARM combination when time allows. I'm currently working on a couple of new things, so it will be a week or two before I get the chance. In the mean time I have some code written by a third party that uses the Keil/ARM tools on a SAM7 that I can provide if required. The SAM7 is also ARM7 based so converting this to run on an LPC2368 is quite straight forward.

One of the problems in supporting the Keil/ARM tools is the limitations of the evaluation version. You can only create applications that have a *combined* code *and* data size of 16KBytes of less. This is not adequate to do anything interesting with TCP/IP.

If you would like a copy of the code then email me at r _dot_ barry [at] freertos.org. Do not use a SourceForge email address as binary attachments will get stripped off.

Converting from SAM7 to LPC would involve:

1) Changing the prvSetupTimerInterrupt() function to use the LPC timer in place of the SAM7 timer. You can use the CrossWorks port as an example of how to do this (should just be able to copy the function out of the CrossWorks port).

2) Changing the interrupt setups to use the LPC VIC in place of the SAM7 AIC.

3) Changing the startup code to use the Keil assembler syntax. Make sure stacks are setup for Supervisor and IRQ modes (as a minimum) and that main() is called from Supervisor mode. There is no need to setup a stack for User mode as the kernel does this for you when you create tasks.

If you download the demo version of CrossWorks then you can open the existing uIP project to see which files need to be included to run the WEB server demo. uIP requires some structures to be packed, and the syntax to do this is compiler dependent. The macro portPACK_STRUCT_END is provided for this purpose. In GCC you set this to __attribute__((packed)), I'm not sure what the Keil equivalent is.


RE: LPC2368 with Keil tools?

Posted by Frank Andersen on May 30, 2007
I would like to have it for IAR tools.

Best regards

Frank Andersen

RE: LPC2368 with Keil tools?

Posted by Richard on May 30, 2007
It should not be too difficult to re-target the existing LPC2129/IAR demo to run on the LPC2368:

+ Change the linker script to be correct for the LPC2368 memory map.

+ Update the timer setup, which is slightly different between the LPC2129 and LPC2368. You can take the code from the Rowley project (prvSetupTimerInterrupt() in port.c).

+ Include the files that are included in the Rowley project.

+ Make sure the uIP structure packing is performed correctly. In IAR you have to use #pragma's in place of the __attribute__(("packed")) used in GCC. There will be an IAR uIP demo in FreeRTOS.org V4.3.0 which will be released in a week or so, although this is not for the LPC2368 you will still be able to use the files.


RE: LPC2368 with Keil tools?

Posted by sashiono on May 30, 2007
What's wrong with using gcc?? I posted up a port a while back

RE: LPC2368 with Keil tools?

Posted by Frank Andersen on July 3, 2007

I am trying to port to the LPC2378 using the IAR compiler. I started with the LPC2129 project.

I have tried to copy the prvSetupTimerIntterupt from the Rowley project, and changed the interrupt entry. But I am not sure if it is correct. It does not work. Any ideas?

Best regards, Frank Andersen

static void prvSetupTimerInterrupt( void )
unsigned portLONG ulCompareMatch;

PCLKSEL0 = (PCLKSEL0 & (~(0x3<<2))) | (0x01 << 2);
T0TCR = 2; /* Stop and reset the timer */
T0CTCR = 0; /* Timer mode */

/* A 1ms tick does not require the use of the timer prescale. This is
defaulted to zero but can be used if necessary. */

/* Calculate the match value required for our wanted tick rate. */
ulCompareMatch = configCPU_CLOCK_HZ / configTICK_RATE_HZ;

/* Protect against divide by zero. Using an if() statement still results
in a warning - hence the #if. */
#if portPRESCALE_VALUE != 0
ulCompareMatch /= ( portPRESCALE_VALUE + 1 );
T0MR1 = ulCompareMatch;

/* Generate tick with timer 0 compare match. */
T0MCR = (3 << 3); /* Reset timer on match and generate interrupt */

/* Setup the VIC for the timer. */
VICINTENABLE = 0x00000010;

/* The ISR installed depends on whether the preemptive or cooperative
scheduler is being used. */
#if configUSE_PREEMPTION == 1
//extern void ( vPreemptiveTick )( void );
//VICVECTADDR4 = ( portLONG ) vPreemptiveTick;

extern void ( vPortPreemptiveTickEntry )( void );
VICVECTADDR4 = ( portLONG ) vPortPreemptiveTickEntry;
extern void ( vNonPreemptiveTick )( void );
VICVectAddr4 = ( portLONG ) vNonPreemptiveTick;


/* Start the timer - interrupts are disabled when this function is called
so it is okay to do this here. */

RE: LPC2368 with Keil tools?

Posted by Dave on July 3, 2007
All looks ok. What is not working? Try just setting up the interrupt outside of FreeRTOS and get it to toggle an LED every second to check the interrupt setup first.


RE: LPC2368 with Keil tools?

Posted by Frank Andersen on July 4, 2007
When the Scheduler is started it just branches to <undefvec> in cstartup.s

It looks to me like the VicVectorAddr for the timer is okay, and the VicAddress holds the address of the timer vPortPreemptiveTick.

Any Ideas?

Best regards, Frank Andersen

RE: LPC2368 with Keil tools?

Posted by Frank Andersen on July 4, 2007
Does anything in the cstartup.s79 file need to be changed in order to work with LPC2378?

I have used the one from LPC2129 port.

Best regards, Frank Andersen

RE: LPC2368 with Keil tools?

Posted by Dave on July 4, 2007
I would think the same startup file could be used. Make sure you are using the one from the other project though. It is easy to accidentally use the one from the IAR installation directory as this is the default when setting up a project.

RE: LPC2368 with Keil tools?

Posted by Frank Andersen on July 5, 2007
Well, in cstartup.s79 the IRQVEC has to be changed to:

LDRPC, [PC, #-0x0120] ; Vector from VicVectAddr

If I put in a while (1); in xPortStartScheduler after prvSetupTimerInterrupt(); and enable interrupts, the timer interrupt is working.

Changed to compile in Thumb, and now the processor keeps runing, but the Flash tast only run once when it is started, the timer interrupt is runing and TickCount is counting...

What to lookk for?

Best regards, Frank Andersen

RE: LPC2368 with Keil tools?

Posted by Frank Andersen on July 6, 2007
Well, now it is running

in SetupTimer I changed, to use match 0 register, for some reason when using match 1 register, the timing on the interrupt did not match, the frequency was 16 kHz.

So in the above setup, changes this:

T0MR0 = ulCompareMatch;

* Generate tick with timer 0 compare match. */
T0MCR = 3;//(3 << 3); /* Reset timer on match and generate interrupt */

Best regards, Frank Andersen

[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]

Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.

Free TCP/IP and file system demos for the RTOS

Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑

FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists