EmbeddedRelated.com
Forums

Need demo for CrossWorks CTL that uses timers and interrupt IO on LPC2129

Started by Peter Klemm August 23, 2008
I am trying to understand how to manage IO with interrupts
when using CrossWorks Tasking Library (CTL). I have a small
program with 3 tasks. Two tasks just blink LEDs and the third
outputs via UART0 using interrupts. I seem to not understand
how to setup interrupts on the LPC2129, or maybe I am not
understanding CTL and interrupt routines.

Anyone have a good example program for CrossWorks with CTL
on an LPC2129?

An Engineer's Guide to the LPC2100 Series

--- In l..., "Peter Klemm" wrote:
>
> I am trying to understand how to manage IO with interrupts
> when using CrossWorks Tasking Library (CTL). I have a small
> program with 3 tasks. Two tasks just blink LEDs and the third
> outputs via UART0 using interrupts. I seem to not understand
> how to setup interrupts on the LPC2129, or maybe I am not
> understanding CTL and interrupt routines.
>
> Anyone have a good example program for CrossWorks with CTL
> on an LPC2129?
>

I'm a little surprised that you're having a problem with this. The
UART interrupts on my Crossworks/ctl app worked the first time I tried
them! By 'worked', I mean that a breakpoint on the interrupt-handler
was hit. I had plenty of bugs after that, but getting the interrupt
to fire was not a problem at all.

Set the ISR, unmask it and turn on the interrupts in the UART. Send
in a char and the CTI interrupt should fire. Load a char into the tx.
FIFO and the THRE interrupt should get called. An ISR in Crossworks
is a simple C void function - beware of using C++ methods since ISRs,
when entered, have no 'this' context.

My code is a bit unhelpful since it's C++ and adheres to an overall
structure that is common to the UARTs and CAN, (and is not really mine
- belongs to employer), but to give a rough idea:
****************************************
void TUART::startUp(){
sUxIER thisIER;
ctl_set_isr(myInterruptInterface->interruptLevel,
myInterruptInterface->interruptLevel,
CTL_ISR_TRIGGER_FIXED,myInterruptInterface->interruptRoutineEntry,0);
ctl_unmask_isr(myInterruptInterface->interruptLevel);
thisIER=myInterruptInterface->pUARTmap->UxIERDLM.UxIER;
thisIER.RBRenable=1;
thisIER.THREenable=1;
thisIER.RLSenable=0;
thisIER.reserved=0;
myInterruptInterface->pUARTmap->UxIERDLM.UxIER=thisIER;
};
****************************************

The interrupt level for UART0 is 6.

Rgds,
Martin