Forums

RTOS and Interrupts on the 2148

Started by nishchay mhatre June 17, 2009
Hi,
I am just getting started on the LPC 2148. Using a Keil uVision IDE demo
version and serial port to download the code into flash.
Should I first port an RTOS to the 2148 before writing software for it (the
application is to control a small solar power system)? If so which freely
available RTOS is suitable (like FreeRTOS)?
Also require help with using the interrupt controller on the 2148. After
enabling the required interrupt and setting it as a vectored interrupt, what
address should I put in the VICVectAddr register? How do I make sure that
the interrupt service procedure will be put in that location and no other? I
am familiar with the vector-table system of the x86 . Is there a fixed
address that I use to put in the VICVectAddr register, or is it the
programmers choice?
Thank you.
-Nishchay


An Engineer's Guide to the LPC2100 Series

Using VicVector each interrupt source will have a different address,
exemple, setting VicVecAddr4 = InterruptRoutineTimer0() you will set to the
function InterruptRoutineTimer0() launch each time the interrupt source 4,
witch is the timer 0, happens. So, by this way you can configure 32 diferent
addresses for the 32 intrerrupts source.

Porting a FreeRTOS isnt a very easy thing to do on Keil once it doesn't uses
the GCC or WINARM compiler. So it has different methods of programation. I
am having a lot of troubles porting a 2129 keil FreeRTOS to 2378.

Hope I helped.

2009/6/17 nishchay mhatre

> Hi,
> I am just getting started on the LPC 2148. Using a Keil uVision IDE demo
> version and serial port to download the code into flash.
> Should I first port an RTOS to the 2148 before writing software for it (the
> application is to control a small solar power system)? If so which freely
> available RTOS is suitable (like FreeRTOS)?
> Also require help with using the interrupt controller on the 2148. After
> enabling the required interrupt and setting it as a vectored interrupt,
> what
> address should I put in the VICVectAddr register? How do I make sure that
> the interrupt service procedure will be put in that location and no other?
> I
> am familiar with the vector-table system of the x86 . Is there a fixed
> address that I use to put in the VICVectAddr register, or is it the
> programmers choice?
> Thank you.
> -Nishchay
>
>
>


Thank you for the prompt reply :)
My main doubt is how to determine the address of the
InterruptRountineTimer0()...
I mean, can I just select a random block of free space in the Flash, big
enough to hold the ISR and set that address in the VICVectAddr?

On Wed, Jun 17, 2009 at 5:24 PM, Felipe de Andrade Neves Lavratti <
f...@gmail.com> wrote:

> Using VicVector each interrupt source will have a different address,
> exemple, setting VicVecAddr4 = InterruptRoutineTimer0() you will set to the
> function InterruptRoutineTimer0() launch each time the interrupt source 4,
> witch is the timer 0, happens. So, by this way you can configure 32
> diferent
> addresses for the 32 intrerrupts source.
>
> Porting a FreeRTOS isnt a very easy thing to do on Keil once it doesn't
> uses
> the GCC or WINARM compiler. So it has different methods of programation. I
> am having a lot of troubles porting a 2129 keil FreeRTOS to 2378.
>
> Hope I helped.
>
> 2009/6/17 nishchay mhatre
> >
> >
> >
> > Hi,
> > I am just getting started on the LPC 2148. Using a Keil uVision IDE demo
> > version and serial port to download the code into flash.
> > Should I first port an RTOS to the 2148 before writing software for it
> (the
> > application is to control a small solar power system)? If so which freely
> > available RTOS is suitable (like FreeRTOS)?
> > Also require help with using the interrupt controller on the 2148. After
> > enabling the required interrupt and setting it as a vectored interrupt,
> > what
> > address should I put in the VICVectAddr register? How do I make sure that
> > the interrupt service procedure will be put in that location and no
> other?
> > I
> > am familiar with the vector-table system of the x86 . Is there a fixed
> > address that I use to put in the VICVectAddr register, or is it the
> > programmers choice?
> > Thank you.
> > -Nishchay
> >
> >
> >
> >
> >
>
>
>

--
~~Jai Hind~~


Look this:

/* Configure T0 to interrupt on 8 and 24 and reset in 32 */
T0MCR=0x89; /* Interrupt on T0MR0 and T0MR1, Reset on T0MR2 */
T0IR=3; /* Interrupts on T0MR0, T0MR1 */
T0MR0 = 7; /* Interrupts when T0TC==8 */
T0MR1 = 23; /* Interrupts when T0TC=$ */
T0MR2 = 31; /* Reset when T0TC=2 */

/* Vectoring the Timer0*/
VICIntSelect &= ~0x10; /* Timer0=bit 4 as IRQ by setting bit 4 as 0*/
VICIntEnable |= 0x10; /* Enable the Timer0 on VIC by setting bit 4 as 1*/
VICVectAddr4 = IRQ_Timer0; /* Here, the address of IRQ_Timer0() is being
passed to the vector */

All you need now is a function called IRQ_Timer0 to awnser the interruption
of timer0.

The prototype:
In GNU: void IRQ_Timer0(void) __attribute__ ((interrupt("IRQ")));
in Keil: void IRQ_Timer0(void) __irq

The function:
void IRQ_Timer0() {
/* procedure here */
VICVectAddr = 0; //This must be done to let the VIC know you
attempted the interrupt
}

That is it.
Hope I helped.

2009/6/17 nishchay mhatre

> Thank you for the prompt reply :)
> My main doubt is how to determine the address of the
> InterruptRountineTimer0()...
> I mean, can I just select a random block of free space in the Flash, big
> enough to hold the ISR and set that address in the VICVectAddr?
>
> On Wed, Jun 17, 2009 at 5:24 PM, Felipe de Andrade Neves Lavratti <
> f...@gmail.com > wrote:
>
> >
> >
> > Using VicVector each interrupt source will have a different address,
> > exemple, setting VicVecAddr4 = InterruptRoutineTimer0() you will set to
> the
> > function InterruptRoutineTimer0() launch each time the interrupt source
> 4,
> > witch is the timer 0, happens. So, by this way you can configure 32
> > diferent
> > addresses for the 32 intrerrupts source.
> >
> > Porting a FreeRTOS isnt a very easy thing to do on Keil once it doesn't
> > uses
> > the GCC or WINARM compiler. So it has different methods of programation.
> I
> > am having a lot of troubles porting a 2129 keil FreeRTOS to 2378.
> >
> > Hope I helped.
> >
> > 2009/6/17 nishchay mhatre
>
> > >
> >
> >
> > >
> > >
> > > Hi,
> > > I am just getting started on the LPC 2148. Using a Keil uVision IDE
> demo
> > > version and serial port to download the code into flash.
> > > Should I first port an RTOS to the 2148 before writing software for it
> > (the
> > > application is to control a small solar power system)? If so which
> freely
> > > available RTOS is suitable (like FreeRTOS)?
> > > Also require help with using the interrupt controller on the 2148.
> After
> > > enabling the required interrupt and setting it as a vectored interrupt,
> > > what
> > > address should I put in the VICVectAddr register? How do I make sure
> that
> > > the interrupt service procedure will be put in that location and no
> > other?
> > > I
> > > am familiar with the vector-table system of the x86 . Is there a fixed
> > > address that I use to put in the VICVectAddr register, or is it the
> > > programmers choice?
> > > Thank you.
> > > -Nishchay
> > >
> > >
> > >
> > >
> > >
> >
> >
> >
> >
> > --
> ~~Jai Hind~~
>
>
>
>
>


Oh yes, that was really helpful.
Many thanks!

On Wed, Jun 17, 2009 at 6:07 PM, Felipe de Andrade Neves Lavratti <
f...@gmail.com> wrote:

> Look this:
>
> /* Configure T0 to interrupt on 8 and 24 and reset in 32 */
> T0MCR=0x89; /* Interrupt on T0MR0 and T0MR1, Reset on T0MR2 */
> T0IR=3; /* Interrupts on T0MR0, T0MR1 */
> T0MR0 = 7; /* Interrupts when T0TC==8 */
> T0MR1 = 23; /* Interrupts when T0TC=$ */
> T0MR2 = 31; /* Reset when T0TC=2 */
>
> /* Vectoring the Timer0*/
> VICIntSelect &= ~0x10; /* Timer0=bit 4 as IRQ by setting bit 4 as 0*/
> VICIntEnable |= 0x10; /* Enable the Timer0 on VIC by setting bit 4 as 1*/
> VICVectAddr4 = IRQ_Timer0; /* Here, the address of IRQ_Timer0() is being
> passed to the vector */
>
> All you need now is a function called IRQ_Timer0 to awnser the interruption
> of timer0.
>
> The prototype:
> In GNU: void IRQ_Timer0(void) __attribute__ ((interrupt("IRQ")));
> in Keil: void IRQ_Timer0(void) __irq
>
> The function:
> void IRQ_Timer0() {
> /* procedure here */
> VICVectAddr = 0; //This must be done to let the VIC know you
> attempted the interrupt
> }
>
> That is it.
>
> Hope I helped.
>
> 2009/6/17 nishchay mhatre
> > >
> >
> > Thank you for the prompt reply :)
> > My main doubt is how to determine the address of the
> > InterruptRountineTimer0()...
> > I mean, can I just select a random block of free space in the Flash, big
> > enough to hold the ISR and set that address in the VICVectAddr?
> >
> > On Wed, Jun 17, 2009 at 5:24 PM, Felipe de Andrade Neves Lavratti <
> > f...@gmail.com >
> wrote:
> >
> > >
> > >
> > > Using VicVector each interrupt source will have a different address,
> > > exemple, setting VicVecAddr4 = InterruptRoutineTimer0() you will set to
> > the
> > > function InterruptRoutineTimer0() launch each time the interrupt source
> > 4,
> > > witch is the timer 0, happens. So, by this way you can configure 32
> > > diferent
> > > addresses for the 32 intrerrupts source.
> > >
> > > Porting a FreeRTOS isnt a very easy thing to do on Keil once it doesn't
> > > uses
> > > the GCC or WINARM compiler. So it has different methods of
> programation.
> > I
> > > am having a lot of troubles porting a 2129 keil FreeRTOS to 2378.
> > >
> > > Hope I helped.
> > >
> > > 2009/6/17 nishchay mhatre
>
> > > > >
> > >
> > >
> > > >
> > > >
> > > > Hi,
> > > > I am just getting started on the LPC 2148. Using a Keil uVision IDE
> > demo
> > > > version and serial port to download the code into flash.
> > > > Should I first port an RTOS to the 2148 before writing software for
> it
> > > (the
> > > > application is to control a small solar power system)? If so which
> > freely
> > > > available RTOS is suitable (like FreeRTOS)?
> > > > Also require help with using the interrupt controller on the 2148.
> > After
> > > > enabling the required interrupt and setting it as a vectored
> interrupt,
> > > > what
> > > > address should I put in the VICVectAddr register? How do I make sure
> > that
> > > > the interrupt service procedure will be put in that location and no
> > > other?
> > > > I
> > > > am familiar with the vector-table system of the x86 . Is there a
> fixed
> > > > address that I use to put in the VICVectAddr register, or is it the
> > > > programmers choice?
> > > > Thank you.
> > > > -Nishchay
> > > >
> > > >
> > > >
> > > >
> > > >
> > >
> > >
> > >
> > >
> > >
> >
> > --
> > ~~Jai Hind~~
> >
> >
> >
> >
> >
>
>
>

--
~~Jai Hind~~


--- In l..., nishchay mhatre wrote:
>
> Thank you for the prompt reply :)
> My main doubt is how to determine the address of the
> InterruptRountineTimer0()...
> I mean, can I just select a random block of free space in the Flash, big
> enough to hold the ISR and set that address in the VICVectAddr?

Hm...

Here is a prototype for Time0 ISR using GCC:

void T0ISR (void) __attribute__ ((interrupt ));

Here is the timer setup code:

volatile unsigned int CurrentTime = 0;

void T0Init(void)
{
// set up Timer 0
T0TC = 0; // clear the timer count
T0PR = 1; // prescale divide by 2
T0MR0 = 29490; // divide by 29490 to get approx 1000 ints per second
T0MCR = 0x03; // interrupt on match, reset on match
T0TCR = 0x01; // start the timer
VICVectCntl3 = 0x00000024; // set priority 3 for Timer 0
VICVectAddr3 = (unsigned long) T0ISR; // pass the address of the ISR
VICIntEnable = 0x00000010; // enable interrupt
}

You can see how easy it is to get the address of the T0ISR and stuff it in VICVectAddr3

Finally, here is the T0 ISR:

void T0ISR(void) // interrupt handler - see timer.h
{
CurrentTime++; // update time
T0IR = 0x01; // clear interrupt
VICVectAddr = 0xFF; clear VICVect
}

Now, save yourself a TON of work by using the GCC toolchain and downloading all of the code (including a port of FreeRTOS) from www.jcwren.com/arm.

If you develop under Windows, just install YAGARTO. If you use Linux, you can download the toolchain by following the instructions at www.gnuarm.org/support.html. The web site is strange. If you go to www.gnuarm.org it will redirect you to YAGARTO.de If you come in through the support page you will find the instructions to build the toolchain and then you click on the Files menu to get the latest source files.

I highly recommend lpc21isp as your serial device programmer. You can get the latest and greatest by joining the lpc21isp group here on YAHOO. You can also benefit from the most recent discussions re: building GNUARM on the GNUARM group here on Yahoo.

Richard

> Porting a FreeRTOS isnt a very easy thing to do on Keil once it doesn't uses
> the GCC or WINARM compiler. So it has different methods of programation. I
> am having a lot of troubles porting a 2129 keil FreeRTOS to 2378.

Moving a demo project from one LPC device to another is not really 'porting'
but an exercise in changing the linker script, and sometimes changing the
timer use in prvSetTimerInterrupt(). There is an LPC/Keil example in the
FreeRTOS download.

Regards,
Richard [FreeRTOS]
Yes, that's what I am trying to do.. many have said it is a simple job but,
for my skills, it's being a pain in the a**.

I've had to do a lot of changing from the LPC23xx.s to the ports, the VIC
interrupts and the Timers.. and I havent got it working yet.
Att
Fanl.
2009/6/17

> > Porting a FreeRTOS isnt a very easy thing to do on Keil once it doesn't
> uses
> > the GCC or WINARM compiler. So it has different methods of programation.
> I
> > am having a lot of troubles porting a 2129 keil FreeRTOS to 2378.
>
> Moving a demo project from one LPC device to another is not really
> 'porting'
> but an exercise in changing the linker script, and sometimes changing the
> timer use in prvSetTimerInterrupt(). There is an LPC/Keil example in the
> FreeRTOS download.
>
> Regards,
> Richard [FreeRTOS]
>


While it's for GCC and not Keil or whatever, you may wish to look at the
port at http://jcwren.com/arm
--jc

On Wed, Jun 17, 2009 at 11:21 AM, Felipe de Andrade Neves Lavratti <
f...@gmail.com> wrote:

> Yes, that's what I am trying to do.. many have said it is a simple job but,
> for my skills, it's being a pain in the a**.
>
> I've had to do a lot of changing from the LPC23xx.s to the ports, the VIC
> interrupts and the Timers.. and I havent got it working yet.
> Att
> Fanl.
> 2009/6/17 > >
> >
> > > Porting a FreeRTOS isnt a very easy thing to do on Keil once it doesn't
> > uses
> > > the GCC or WINARM compiler. So it has different methods of
> programation.
> > I
> > > am having a lot of troubles porting a 2129 keil FreeRTOS to 2378.
> >
> > Moving a demo project from one LPC device to another is not really
> > 'porting'
> > but an exercise in changing the linker script, and sometimes changing the
> > timer use in prvSetTimerInterrupt(). There is an LPC/Keil example in the
> > FreeRTOS download.
> >
> > Regards,
> > Richard [FreeRTOS]
> >
> >
> >
>
>
>


Hi all,
I need to clear some concepts regarding RTOS.
I know what makes an RTOS different from an OS like Linux or Windows XP and
I think I might need to use an RTOS for this project.
But how exactly is an RTOS used? This is my rough idea:
You first port the RTOS to your hardware (which is analogous to installing
an OS on your pc (?) ).
Then there must be some kind of shell which helps you to write programs that
will run on the RTOS -hardware platform. So through the host computer we
access this shell and do the needful.
Is this the right idea? Please correct me.
Also, how do I do this practically. Suppose I have to port an RTLinux onto
an LPC2148...
What hardware, software and procedure should I use?
Thank you,

-Nishchay
On Wed, Jun 17, 2009 at 11:26 PM, J.C. Wren wrote:

> While it's for GCC and not Keil or whatever, you may wish to look at the
> port at http://jcwren.com/arm
> --jc
> On Wed, Jun 17, 2009 at 11:21 AM, Felipe de Andrade Neves Lavratti <
> f...@gmail.com > wrote:
>
> >
> >
> > Yes, that's what I am trying to do.. many have said it is a simple job
> but,
> > for my skills, it's being a pain in the a**.
> >
> > I've had to do a lot of changing from the LPC23xx.s to the ports, the VIC
> > interrupts and the Timers.. and I havent got it working yet.
> > Att
> > Fanl.
> > 2009/6/17 > 40freertos.org>>
> >
> > >
> > >
> > > > Porting a FreeRTOS isnt a very easy thing to do on Keil once it
> doesn't
> > > uses
> > > > the GCC or WINARM compiler. So it has different methods of
> > programation.
> > > I
> > > > am having a lot of troubles porting a 2129 keil FreeRTOS to 2378.
> > >
> > > Moving a demo project from one LPC device to another is not really
> > > 'porting'
> > > but an exercise in changing the linker script, and sometimes changing
> the
> > > timer use in prvSetTimerInterrupt(). There is an LPC/Keil example in
> the
> > > FreeRTOS download.
> > >
> > > Regards,
> > > Richard [FreeRTOS]
> > >
> > >
> > >
> >
> >
> >
> >
> >
>
>
>

--
~~Jai Hind~~