LPC23xx

I already seen some discussions about LPC2368 in the forum, I didn’t
find it for IAR at the new versions of IAR, so I suppose that “work”
it’s not so easy that they don’t share or not possible :-). I had bought books trying to understand better the process, but in
fact, I can’t go ahead, and I already use the project, try to combine
the .S file, already ported the TIMER, use the LPC23 GCC example and
files, and up to know, the timer goes OK, the main it’s called in
supervisor mode, but sometimes it end’s in a data_abort, or other
errors… When I change the ASM ( port SAVE and port RESTORE ) it change the
result, but in fact, I can go far with it. The big issue is that in IAR there is no possible to call the code
like in GCC ( because of naked attribute – that’s why the code use ASM
MACRO ) So how to make SAVE and RESTORE totaly compatible calling this 2 lines :        ( void ) ulCriticalNesting;                                                                                    
       ( void ) pxCurrentTCB;                                                                                          Like in GCC project port, or even better, does anybode has a project ported to IAR? One another question, trying to work in the IRQ for timer interruption , at the preempitive mode, the code says that we can user directives like __arm __irq , but when I try this interruptions without this directives the code generate some instable result, it’s really unecessary? there is problem to use? like this : 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. */
T0PR = portPRESCALE_VALUE; /* 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 );
}
#endif
// T0MR0 = ulCompareMatch;
/* Generate tick with timer 0 compare match. */
T0MCR  = 3;//(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 ) vPortPreemptiveTick;
}
#else
{
extern void ( vNonPreemptiveTick )( void );
VICVECTADDR4 = ( portLONG ) vPortNonPreemptiveTick;
}
#endif VICVECTPRIORITY4 = 1; /* Start the timer – interrupts are disabled when this function is called
so it is okay to do this here. */
T0TCR = 1; } __arm __irq void vPortPreemptiveTick( void );
__arm __irq void vPortPreemptiveTick( void )
{
/* Increment the tick counter. */
//vTaskIncrementTick(); /* The new tick value might unblock a task.  Ensure the highest task that
is ready to execute is the task that will execute when the tick ISR
exits. */
//vTaskSwitchContext(); /* Ready for the next interrupt. */
__disable_interrupt();
T0IR = 1;
VICADDRESS = 0;
__enable_interrupt();
} Best regards

LPC23xx

I already seen some discussions about LPC2368 in the forum, I didn’t
find it for IAR at the new versions of IAR, so I suppose that “work”
it’s not so easy that they don’t share or not possible :-).
There is an IAR port layer for the LPC2000, with accompanying demo projects.  Converting this to be correct for the LPC23xx should not be a big job, and it sounds like you have an understanding of what is required already. There are already LPC2000 and LPC23xx port layers for GCC, and these can be examined to see what the differences are.  However, the syntax required between GCC and IAR is going to be very different, so its best to start with the IAR files, then edit the files as required to make them correct for the 2368. One way to do this would be to: 1) In the FreeRTOS directory tree, create a directory called FreeRTOSSourceportableIARLPC23xx, and into this directory copy all the files from the FreeRTOSSourceportableIARLPC2000 directory.  This will hold the modified port layer files. 2) Also create a directory called FreeRTOSDemoARM7_LPC2368_IAR, and into this directory copy all the files from the FreeRTOSDemoARM7_LPC2129_IAR directory.  This will hold the demo project workspace and files. 3) In IAR Embedded Workbench, open up the .eww file located in the new FreeRTOSDemoARM7_LPC2368_IAR directory and check that it builds.  This will then be a good starting point, albeit targeted at the wrong CPU derivative. 4) In the IAR project workspace you will see a folder called “Scheduler Source”.  From that folder (within the IDE) remove port.c and portasm.s79 as these will be located in the LPC2000 directory.  In their place add the files that have the same names from the directory created in step (1) above.  Try compiling again – no idea what will happen but it should still compile as the files thus far are identical. 5) Bring up the project options by pressing ALT+F7.  Under the category “General Options” (comes up by default) you will see a tab called “Target” on which you can select the LPC2368 as the CPU derivative.   Next select the linker category, and ensure the linker file being used is correct for the LPC2368 . 6) Open up FreeRTOSConfig.h from the demo directory created in step (2).  At the top you will see a device specific header file being included – change this to be correct for the LPC2368. 7) Next you will have to inspect and compare the Source/Portable/LPC2000 and Source/Portable/LPC23xx files to see what differences there are and make the same changes to the IAR equivalents that are now included in your IAR workspace.  As you already mentioned the timer configuration is a bit different, but you should be able to see the differences easily enough.
When I change the ASM ( port SAVE and port RESTORE ) it change the
result, but in fact, I can go far with it.
You should not need to change any asm code (probably), but with the IAR projects the interrupt service routines need wrappers that are placed in asm files – whereas the GCC equivalent uses naked functions in C files instead.  See the section “An example of an ISR with context switching capabilities” on the following page http://www.freertos.org/portlpciar.html .
The big issue is that in IAR there is no possible to call the code
like in GCC ( because of naked attribute – that’s why the code use ASM
MACRO )
So how to make SAVE and RESTORE totaly compatible calling this 2 lines :        ( void ) ulCriticalNesting;                                                                                    
       ( void ) pxCurrentTCB;                                                                                          Creating your project from the existing LPC2000 project as described about should prevent you having to change anything, I think. Regards.

LPC23xx

Hi Richard, Now I find my way… some issues are solved when I ready the Keil port considerations, and make the 4th time migration from scrath… there is some issues because the port.c the .s start up, the portasm, and mainly the IRQ problems and differences from 2129 and 2368. Best regards,
Vinicius