EmbeddedRelated.com
Forums

Problem with Timers and VICVectors on CrossWorks.

Started by nimster6969 May 1, 2008
Pedro,

The number in VICVectAddr n is NOT the priority, but the interrupt source.

Timer0 is interrupt source #4 for the VIC. Lookup "VIC sources" in the uC's
manual!

You cannot CHOOSE a VICVectAddr! They are tied to specific peripherals.

Don't worry about priorities! You have only one ISR.

Look at the sample code for which I gave the link in a previous message.

~ Paul Claessen

From: l... [mailto:l...] On Behalf Of
nimster6969
Sent: Friday, May 02, 2008 4:17 PM
To: l...
Subject: [lpc2000] Re: Problem with Timers and VICVectors on CrossWorks.

Thnx for all the help you been giving Paul, I've put the while cycle
right after the Init(); but still doest work...i think its suposed to
get at least the message from the debug_printf as soon as the ISR is
called...but is not happening...it seems the ISR is never called.About
the VICVectAddr and VICVectCntl i've checked the datasheet from
LPC2103 from philips and from what i've understand I can choose 0-15
since they are prioritised by order...choosing the VICVectAddr0 wich
is linked to VICVectCntl0 im giving this interrupt the highest
priority using the "0" instead of the "4" you mentioned (im probably
telling whole wrong) using VICVectCntl = 0x24 im already enabling the
IRQ slot and making the ISR request to the timer0 wich is placed in
"4" according to the datasheet. 0x24 gives 100100 in bin enabling the
5th bit the IRQ slot and the timer 0. Once again thnx for all your
time, about the URL that you send me in the example they are using FIQ
but I got some understanding of that about the cycle mostly.

Pedro Rodrigues

--- In l... , "Paul
Claessen" wrote:
>
> Get the sample 'LED blink through timer interrupt' program (See Timer
> directory) here:
>
> http://tinyurl.com/2x2dfj
>
> ~ Paul Claessen
>
> From: l...
[mailto:l... ] On
Behalf Of
> nimster6969
> Sent: Friday, May 02, 2008 1:34 PM
> To: l...
> Subject: [lpc2000] Re: Problem with Timers and VICVectors on CrossWorks.
>
> Yeah I know :( its very hard to get those books here in Portugal, I
> dont want anyone to do the work for me, that way I'll never
> learn...I've changed my code to:
>
> //Init Timers
> T0TC = 0;
> T0PR = 0x03; // Load prescaler for 5Ms on Timer
> T0TCR = 0x02; // Reset timer and prescaler
> T0MCR = 0x3; // MCR Config
> T0MR0 = 0xB98C; // Get to 47500
> T0TCR = 0x1; // Enable timer
>
> //Init VIC Vectors
> VICVectAddr0=(unsigned)led_blink; // Set the timer ISR vector address
> VICVectCntl0 = 0x24; // Set channel 0 and source #4
> VICIntEnable = 0x00000010; // Enable the interrupt
> __ARMLIB_enableIRQ();
> }
> //----------------------
> //Program
> //----------------------
>
> void led_blink(void)
> {
> debug_printf("Working");
> T0IR = 0x01; // Clear time of interrupt
> VICVectAddr = 0xFF; // Dummy write to signal end of interrupt
> }
>
> int main()
> {
> Init();
> }
>
> I've done the debug_printf to test if the interrupt is working but is
> not, i've done a step by step debug and the Init(); function works
> well but it doesnt make the ISR instruction.
> Sorry about those questions is cause in my university people are
> supose to choose some projects and do them with a uC teachers help
> mostly with PIC and ARV and I've choosed to work on ARM on my own so
> every thing that I made its really me and its from the things i've
> read not with help of anyone, I know its small things but its a
> beginning, I've made a party only for putting leds blinking with delay
> :). Well once again thax for all the help, will try to get those books
> online.
>
> --- In l...
,
"Paul
> Claessen" wrote:
> >
> > rimster6969,
> >
> > You really do need at least some basic knowledge before you start
> programming embedded systems.
> > If you don't understand basic concepts like interrupts (and let's be
> brutally honest here: you don't), you are not going to get very far.
> > Having us write your programs isn't going to teach you much.
> > Begin with reading some basic embedded programming books.
> > I can recommend: Programming Embedded Systems, by Michael Barr &
> Anthony Massa (O'Reilly)
> > and Designing Embedded Hardware by John Catsoulis (O'Reilly)
> >
> > As for your program, follow mjames_doveridge's advice below.
> > You may want to consider reprogramming the timer in the main 'while'
> loop, based on a flag that you set in your ISR, just to get used to
> the idea to keep your ISR as short and sweet as possible.
> >
> > As for your question:
> > "about the other question is it possible to read the TC value so I
> can count how many cycles have been made? "
> >
> > Yes, you can read it. This is basic information available from any
> decent datasheet or manual.
> > But why read TC? It will be zero!
> > You want to wait, say, 1000 pclk cycles. So you program the timer
> with that. Your timer goes off when it reaches 0.
> > So guess how many cycles have been made!
> >
> > ~ Paul Claessen
> >
> >
> > ----- Original Message -----
> > From: mjames_doveridge
> > To: l...

> > Sent: Friday, May 02, 2008 1:05 AM
> > Subject: [lpc2000] Re: Problem with Timers and VICVectors on
CrossWorks.
> >
> >
> > --- In l...
,
> "nimster6969" wrote:
> > >
> > > I've put my main like this, is that ok? Where do i need to reprogram
> > > the timers? Thnx
> > >
> > > int main()
> > > {
> > > Init();
> > > led_blink();
> > > }
> > >
> > >
> >
> > Like Paul said, why are you calling the interrupt handler continually
> > in main()? That just kills the interrupt and lights your LED at
> > half-brightness as the uC flashes it at full speed.
> >
> > Keep the while loop. Keep the init and get rid of the explicit call
> > to the handler.
> >
> > int main()
> > {
> > Init();
> > while (1)
> > {
> > // led_blink();
> > }
> > }
> >
> > If you want to reprogram the timer, do it in the interrupt handler
> > after swapping the LED state.
> >
> > Once you understand interrupts, you will be able to progress.
> >
> >
> >
> >
> >
> >
> >
>


An Engineer's Guide to the LPC2100 Series

Pedro,

As for that sample, it really uses IRQ, not FIQ. Study timer.c (in
common.src) carefully!

~ Pal Claessen

From: l... [mailto:l...] On Behalf Of
nimster6969
Sent: Friday, May 02, 2008 4:17 PM
To: l...
Subject: [lpc2000] Re: Problem with Timers and VICVectors on CrossWorks.

Thnx for all the help you been giving Paul, I've put the while cycle
right after the Init(); but still doest work...i think its suposed to
get at least the message from the debug_printf as soon as the ISR is
called...but is not happening...it seems the ISR is never called.About
the VICVectAddr and VICVectCntl i've checked the datasheet from
LPC2103 from philips and from what i've understand I can choose 0-15
since they are prioritised by order...choosing the VICVectAddr0 wich
is linked to VICVectCntl0 im giving this interrupt the highest
priority using the "0" instead of the "4" you mentioned (im probably
telling whole wrong) using VICVectCntl = 0x24 im already enabling the
IRQ slot and making the ISR request to the timer0 wich is placed in
"4" according to the datasheet. 0x24 gives 100100 in bin enabling the
5th bit the IRQ slot and the timer 0. Once again thnx for all your
time, about the URL that you send me in the example they are using FIQ
but I got some understanding of that about the cycle mostly.

Pedro Rodrigues

--- In l... , "Paul
Claessen" wrote:
>
> Get the sample 'LED blink through timer interrupt' program (See Timer
> directory) here:
>
> http://tinyurl.com/2x2dfj
>
> ~ Paul Claessen
>
> From: l...
[mailto:l... ] On
Behalf Of
> nimster6969
> Sent: Friday, May 02, 2008 1:34 PM
> To: l...
> Subject: [lpc2000] Re: Problem with Timers and VICVectors on CrossWorks.
>
> Yeah I know :( its very hard to get those books here in Portugal, I
> dont want anyone to do the work for me, that way I'll never
> learn...I've changed my code to:
>
> //Init Timers
> T0TC = 0;
> T0PR = 0x03; // Load prescaler for 5Ms on Timer
> T0TCR = 0x02; // Reset timer and prescaler
> T0MCR = 0x3; // MCR Config
> T0MR0 = 0xB98C; // Get to 47500
> T0TCR = 0x1; // Enable timer
>
> //Init VIC Vectors
> VICVectAddr0=(unsigned)led_blink; // Set the timer ISR vector address
> VICVectCntl0 = 0x24; // Set channel 0 and source #4
> VICIntEnable = 0x00000010; // Enable the interrupt
> __ARMLIB_enableIRQ();
> }
> //----------------------
> //Program
> //----------------------
>
> void led_blink(void)
> {
> debug_printf("Working");
> T0IR = 0x01; // Clear time of interrupt
> VICVectAddr = 0xFF; // Dummy write to signal end of interrupt
> }
>
> int main()
> {
> Init();
> }
>
> I've done the debug_printf to test if the interrupt is working but is
> not, i've done a step by step debug and the Init(); function works
> well but it doesnt make the ISR instruction.
> Sorry about those questions is cause in my university people are
> supose to choose some projects and do them with a uC teachers help
> mostly with PIC and ARV and I've choosed to work on ARM on my own so
> every thing that I made its really me and its from the things i've
> read not with help of anyone, I know its small things but its a
> beginning, I've made a party only for putting leds blinking with delay
> :). Well once again thax for all the help, will try to get those books
> online.
>
> --- In l...
,
"Paul
> Claessen" wrote:
> >
> > rimster6969,
> >
> > You really do need at least some basic knowledge before you start
> programming embedded systems.
> > If you don't understand basic concepts like interrupts (and let's be
> brutally honest here: you don't), you are not going to get very far.
> > Having us write your programs isn't going to teach you much.
> > Begin with reading some basic embedded programming books.
> > I can recommend: Programming Embedded Systems, by Michael Barr &
> Anthony Massa (O'Reilly)
> > and Designing Embedded Hardware by John Catsoulis (O'Reilly)
> >
> > As for your program, follow mjames_doveridge's advice below.
> > You may want to consider reprogramming the timer in the main 'while'
> loop, based on a flag that you set in your ISR, just to get used to
> the idea to keep your ISR as short and sweet as possible.
> >
> > As for your question:
> > "about the other question is it possible to read the TC value so I
> can count how many cycles have been made? "
> >
> > Yes, you can read it. This is basic information available from any
> decent datasheet or manual.
> > But why read TC? It will be zero!
> > You want to wait, say, 1000 pclk cycles. So you program the timer
> with that. Your timer goes off when it reaches 0.
> > So guess how many cycles have been made!
> >
> > ~ Paul Claessen
> >
> >
> > ----- Original Message -----
> > From: mjames_doveridge
> > To: l...

> > Sent: Friday, May 02, 2008 1:05 AM
> > Subject: [lpc2000] Re: Problem with Timers and VICVectors on
CrossWorks.
> >
> >
> > --- In l...
,
> "nimster6969" wrote:
> > >
> > > I've put my main like this, is that ok? Where do i need to reprogram
> > > the timers? Thnx
> > >
> > > int main()
> > > {
> > > Init();
> > > led_blink();
> > > }
> > >
> > >
> >
> > Like Paul said, why are you calling the interrupt handler continually
> > in main()? That just kills the interrupt and lights your LED at
> > half-brightness as the uC flashes it at full speed.
> >
> > Keep the while loop. Keep the init and get rid of the explicit call
> > to the handler.
> >
> > int main()
> > {
> > Init();
> > while (1)
> > {
> > // led_blink();
> > }
> > }
> >
> > If you want to reprogram the timer, do it in the interrupt handler
> > after swapping the LED state.
> >
> > Once you understand interrupts, you will be able to progress.
> >
> >
> >
> >
> >
> >
> >
>


Ok, thnx :) I was able to get ebooks from the books you told me and
gonna study the example you send me and try to understand more about
the timers and interrupts...if i had any doubt will post, changed the
VIC to 4 but still doesnt work will try to find the answer with some
reading. Once again thanx for all the help.

Pedro R.

--- In l..., "Paul Claessen" wrote:
>
> Pedro,
>
>
>
> As for that sample, it really uses IRQ, not FIQ. Study timer.c (in
> common.src) carefully!
>
>
>
> ~ Pal Claessen
>
>
>
> From: l... [mailto:l...] On
Behalf Of
> nimster6969
> Sent: Friday, May 02, 2008 4:17 PM
> To: l...
> Subject: [lpc2000] Re: Problem with Timers and VICVectors on CrossWorks.
>
>
>
> Thnx for all the help you been giving Paul, I've put the while cycle
> right after the Init(); but still doest work...i think its suposed to
> get at least the message from the debug_printf as soon as the ISR is
> called...but is not happening...it seems the ISR is never called.About
> the VICVectAddr and VICVectCntl i've checked the datasheet from
> LPC2103 from philips and from what i've understand I can choose 0-15
> since they are prioritised by order...choosing the VICVectAddr0 wich
> is linked to VICVectCntl0 im giving this interrupt the highest
> priority using the "0" instead of the "4" you mentioned (im probably
> telling whole wrong) using VICVectCntl = 0x24 im already enabling the
> IRQ slot and making the ISR request to the timer0 wich is placed in
> "4" according to the datasheet. 0x24 gives 100100 in bin enabling the
> 5th bit the IRQ slot and the timer 0. Once again thnx for all your
> time, about the URL that you send me in the example they are using FIQ
> but I got some understanding of that about the cycle mostly.
>
> Pedro Rodrigues
>
> --- In l... ,
"Paul
> Claessen" wrote:
> >
> > Get the sample 'LED blink through timer interrupt' program (See Timer
> > directory) here:
> >
> >
> >
> > http://tinyurl.com/2x2dfj
> >
> >
> >
> > ~ Paul Claessen
> >
> >
> >
> > From: l...
> [mailto:l... ] On
> Behalf Of
> > nimster6969
> > Sent: Friday, May 02, 2008 1:34 PM
> > To: l...
> > Subject: [lpc2000] Re: Problem with Timers and VICVectors on
CrossWorks.
> >
> >
> >
> > Yeah I know :( its very hard to get those books here in Portugal, I
> > dont want anyone to do the work for me, that way I'll never
> > learn...I've changed my code to:
> >
> > //Init Timers
> > T0TC = 0;
> > T0PR = 0x03; // Load prescaler for 5Ms on Timer
> > T0TCR = 0x02; // Reset timer and prescaler
> > T0MCR = 0x3; // MCR Config
> > T0MR0 = 0xB98C; // Get to 47500
> > T0TCR = 0x1; // Enable timer
> >
> > //Init VIC Vectors
> > VICVectAddr0=(unsigned)led_blink; // Set the timer ISR vector address
> > VICVectCntl0 = 0x24; // Set channel 0 and source #4
> > VICIntEnable = 0x00000010; // Enable the interrupt
> > __ARMLIB_enableIRQ();
> > }
> > //----------------------
> > //Program
> > //----------------------
> >
> > void led_blink(void)
> > {
> > debug_printf("Working");
> > T0IR = 0x01; // Clear time of interrupt
> > VICVectAddr = 0xFF; // Dummy write to signal end of interrupt
> > }
> >
> > int main()
> > {
> > Init();
> > }
> >
> > I've done the debug_printf to test if the interrupt is working but is
> > not, i've done a step by step debug and the Init(); function works
> > well but it doesnt make the ISR instruction.
> > Sorry about those questions is cause in my university people are
> > supose to choose some projects and do them with a uC teachers help
> > mostly with PIC and ARV and I've choosed to work on ARM on my own so
> > every thing that I made its really me and its from the things i've
> > read not with help of anyone, I know its small things but its a
> > beginning, I've made a party only for putting leds blinking with delay
> > :). Well once again thax for all the help, will try to get those books
> > online.
> >
> > --- In l...
> ,
> "Paul
> > Claessen" wrote:
> > >
> > > rimster6969,
> > >
> > > You really do need at least some basic knowledge before you start
> > programming embedded systems.
> > > If you don't understand basic concepts like interrupts (and let's be
> > brutally honest here: you don't), you are not going to get very far.
> > > Having us write your programs isn't going to teach you much.
> > > Begin with reading some basic embedded programming books.
> > > I can recommend: Programming Embedded Systems, by Michael Barr &
> > Anthony Massa (O'Reilly)
> > > and Designing Embedded Hardware by John Catsoulis (O'Reilly)
> > >
> > > As for your program, follow mjames_doveridge's advice below.
> > > You may want to consider reprogramming the timer in the main 'while'
> > loop, based on a flag that you set in your ISR, just to get used to
> > the idea to keep your ISR as short and sweet as possible.
> > >
> > > As for your question:
> > > "about the other question is it possible to read the TC value so I
> > can count how many cycles have been made? "
> > >
> > > Yes, you can read it. This is basic information available from any
> > decent datasheet or manual.
> > > But why read TC? It will be zero!
> > > You want to wait, say, 1000 pclk cycles. So you program the timer
> > with that. Your timer goes off when it reaches 0.
> > > So guess how many cycles have been made!
> > >
> > > ~ Paul Claessen
> > >
> > >
> > > ----- Original Message -----
> > > From: mjames_doveridge
> > > To: l...
>
> > > Sent: Friday, May 02, 2008 1:05 AM
> > > Subject: [lpc2000] Re: Problem with Timers and VICVectors on
> CrossWorks.
> > >
> > >
> > > --- In l...
> ,
> > "nimster6969" wrote:
> > > >
> > > > I've put my main like this, is that ok? Where do i need to
reprogram
> > > > the timers? Thnx
> > > >
> > > > int main()
> > > > {
> > > > Init();
> > > > led_blink();
> > > > }
> > > >
> > > >
> > >
> > > Like Paul said, why are you calling the interrupt handler
continually
> > > in main()? That just kills the interrupt and lights your LED at
> > > half-brightness as the uC flashes it at full speed.
> > >
> > > Keep the while loop. Keep the init and get rid of the explicit call
> > > to the handler.
> > >
> > > int main()
> > > {
> > > Init();
> > > while (1)
> > > {
> > > // led_blink();
> > > }
> > > }
> > >
> > > If you want to reprogram the timer, do it in the interrupt handler
> > > after swapping the LED state.
> > >
> > > Once you understand interrupts, you will be able to progress.
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> >
> >
> >
> >
> >
> >
> >
>
>
>

Pedro,

Disregard what I said about the VICVectAddr ...
What I said is true for the LPC23xx. I just noticed however, that you're using an LPC21xx and VIC handling for LPC21/22xx is different from the LPC23xx.
So that part you did right.
Sorry for the confusion,

~ Paul Claessen

----- Original Message -----
From: nimster6969
To: l...
Sent: Friday, May 02, 2008 8:06 PM
Subject: [lpc2000] Re: Problem with Timers and VICVectors on CrossWorks.
Ok, thnx :) I was able to get ebooks from the books you told me and
gonna study the example you send me and try to understand more about
the timers and interrupts...if i had any doubt will post, changed the
VIC to 4 but still doesnt work will try to find the answer with some
reading. Once again thanx for all the help.

Pedro R.

--- In l..., "Paul Claessen" wrote:
>
> Pedro,
>
> As for that sample, it really uses IRQ, not FIQ. Study timer.c (in
> common.src) carefully!
>
> ~ Pal Claessen
>
> From: l... [mailto:l...] On
Behalf Of
> nimster6969
> Sent: Friday, May 02, 2008 4:17 PM
> To: l...
> Subject: [lpc2000] Re: Problem with Timers and VICVectors on CrossWorks.
>
> Thnx for all the help you been giving Paul, I've put the while cycle
> right after the Init(); but still doest work...i think its suposed to
> get at least the message from the debug_printf as soon as the ISR is
> called...but is not happening...it seems the ISR is never called.About
> the VICVectAddr and VICVectCntl i've checked the datasheet from
> LPC2103 from philips and from what i've understand I can choose 0-15
> since they are prioritised by order...choosing the VICVectAddr0 wich
> is linked to VICVectCntl0 im giving this interrupt the highest
> priority using the "0" instead of the "4" you mentioned (im probably
> telling whole wrong) using VICVectCntl = 0x24 im already enabling the
> IRQ slot and making the ISR request to the timer0 wich is placed in
> "4" according to the datasheet. 0x24 gives 100100 in bin enabling the
> 5th bit the IRQ slot and the timer 0. Once again thnx for all your
> time, about the URL that you send me in the example they are using FIQ
> but I got some understanding of that about the cycle mostly.
>
> Pedro Rodrigues
>
> --- In l... ,
"Paul
> Claessen" wrote:
> >
> > Get the sample 'LED blink through timer interrupt' program (See Timer
> > directory) here:
> >
> >
> >
> > http://tinyurl.com/2x2dfj
> >
> >
> >
> > ~ Paul Claessen
> >
> >
> >
> > From: l...
> [mailto:l... ] On
> Behalf Of
> > nimster6969
> > Sent: Friday, May 02, 2008 1:34 PM
> > To: l...
> > Subject: [lpc2000] Re: Problem with Timers and VICVectors on
CrossWorks.
> >
> >
> >
> > Yeah I know :( its very hard to get those books here in Portugal, I
> > dont want anyone to do the work for me, that way I'll never
> > learn...I've changed my code to:
> >
> > //Init Timers
> > T0TC = 0;
> > T0PR = 0x03; // Load prescaler for 5Ms on Timer
> > T0TCR = 0x02; // Reset timer and prescaler
> > T0MCR = 0x3; // MCR Config
> > T0MR0 = 0xB98C; // Get to 47500
> > T0TCR = 0x1; // Enable timer
> >
> > //Init VIC Vectors
> > VICVectAddr0=(unsigned)led_blink; // Set the timer ISR vector address
> > VICVectCntl0 = 0x24; // Set channel 0 and source #4
> > VICIntEnable = 0x00000010; // Enable the interrupt
> > __ARMLIB_enableIRQ();
> > }
> > //----------------------
> > //Program
> > //----------------------
> >
> > void led_blink(void)
> > {
> > debug_printf("Working");
> > T0IR = 0x01; // Clear time of interrupt
> > VICVectAddr = 0xFF; // Dummy write to signal end of interrupt
> > }
> >
> > int main()
> > {
> > Init();
> > }
> >
> > I've done the debug_printf to test if the interrupt is working but is
> > not, i've done a step by step debug and the Init(); function works
> > well but it doesnt make the ISR instruction.
> > Sorry about those questions is cause in my university people are
> > supose to choose some projects and do them with a uC teachers help
> > mostly with PIC and ARV and I've choosed to work on ARM on my own so
> > every thing that I made its really me and its from the things i've
> > read not with help of anyone, I know its small things but its a
> > beginning, I've made a party only for putting leds blinking with delay
> > :). Well once again thax for all the help, will try to get those books
> > online.
> >
> > --- In l...
> ,
> "Paul
> > Claessen" wrote:
> > >
> > > rimster6969,
> > >
> > > You really do need at least some basic knowledge before you start
> > programming embedded systems.
> > > If you don't understand basic concepts like interrupts (and let's be
> > brutally honest here: you don't), you are not going to get very far.
> > > Having us write your programs isn't going to teach you much.
> > > Begin with reading some basic embedded programming books.
> > > I can recommend: Programming Embedded Systems, by Michael Barr &
> > Anthony Massa (O'Reilly)
> > > and Designing Embedded Hardware by John Catsoulis (O'Reilly)
> > >
> > > As for your program, follow mjames_doveridge's advice below.
> > > You may want to consider reprogramming the timer in the main 'while'
> > loop, based on a flag that you set in your ISR, just to get used to
> > the idea to keep your ISR as short and sweet as possible.
> > >
> > > As for your question:
> > > "about the other question is it possible to read the TC value so I
> > can count how many cycles have been made? "
> > >
> > > Yes, you can read it. This is basic information available from any
> > decent datasheet or manual.
> > > But why read TC? It will be zero!
> > > You want to wait, say, 1000 pclk cycles. So you program the timer
> > with that. Your timer goes off when it reaches 0.
> > > So guess how many cycles have been made!
> > >
> > > ~ Paul Claessen
> > >
> > >
> > > ----- Original Message -----
> > > From: mjames_doveridge
> > > To: l...
>
> > > Sent: Friday, May 02, 2008 1:05 AM
> > > Subject: [lpc2000] Re: Problem with Timers and VICVectors on
> CrossWorks.
> > >
> > >
> > > --- In l...
> ,
> > "nimster6969" wrote:
> > > >
> > > > I've put my main like this, is that ok? Where do i need to
reprogram
> > > > the timers? Thnx
> > > >
> > > > int main()
> > > > {
> > > > Init();
> > > > led_blink();
> > > > }
> > > >
> > > >
> > >
> > > Like Paul said, why are you calling the interrupt handler
continually
> > > in main()? That just kills the interrupt and lights your LED at
> > > half-brightness as the uC flashes it at full speed.
> > >
> > > Keep the while loop. Keep the init and get rid of the explicit call
> > > to the handler.
> > >
> > > int main()
> > > {
> > > Init();
> > > while (1)
> > > {
> > > // led_blink();
> > > }
> > > }
> > >
> > > If you want to reprogram the timer, do it in the interrupt handler
> > > after swapping the LED state.
> > >
> > > Once you understand interrupts, you will be able to progress.
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> >
> >
> >
> >
> >
> >
> >
>


Pedro

Go to: http://tinyurl.com/5ngphq

And download (right click: save target as..) (and read):

AN10254 Handling Interrupts Using IRQ and IFQ for LPC2000 Microcontrollers

~ Paul

From: l... [mailto:l...] On Behalf Of
Paul Claessen
Sent: Sunday, May 04, 2008 9:05 AM
To: l...
Subject: Re: [lpc2000] Re: Problem with Timers and VICVectors on CrossWorks.

Pedro,

Disregard what I said about the VICVectAddr ...
What I said is true for the LPC23xx. I just noticed however, that you're
using an LPC21xx and VIC handling for LPC21/22xx is different from the
LPC23xx.
So that part you did right.
Sorry for the confusion,

~ Paul Claessen

----- Original Message -----
From: nimster6969
To: l...
Sent: Friday, May 02, 2008 8:06 PM
Subject: [lpc2000] Re: Problem with Timers and VICVectors on CrossWorks.

Ok, thnx :) I was able to get ebooks from the books you told me and
gonna study the example you send me and try to understand more about
the timers and interrupts...if i had any doubt will post, changed the
VIC to 4 but still doesnt work will try to find the answer with some
reading. Once again thanx for all the help.

Pedro R.

--- In l... , "Paul
Claessen" wrote:
>
> Pedro,
>
> As for that sample, it really uses IRQ, not FIQ. Study timer.c (in
> common.src) carefully!
>
> ~ Pal Claessen
>
> From: l...
[mailto:l... ] On
Behalf Of
> nimster6969
> Sent: Friday, May 02, 2008 4:17 PM
> To: l...
> Subject: [lpc2000] Re: Problem with Timers and VICVectors on CrossWorks.
>
> Thnx for all the help you been giving Paul, I've put the while cycle
> right after the Init(); but still doest work...i think its suposed to
> get at least the message from the debug_printf as soon as the ISR is
> called...but is not happening...it seems the ISR is never called.About
> the VICVectAddr and VICVectCntl i've checked the datasheet from
> LPC2103 from philips and from what i've understand I can choose 0-15
> since they are prioritised by order...choosing the VICVectAddr0 wich
> is linked to VICVectCntl0 im giving this interrupt the highest
> priority using the "0" instead of the "4" you mentioned (im probably
> telling whole wrong) using VICVectCntl = 0x24 im already enabling the
> IRQ slot and making the ISR request to the timer0 wich is placed in
> "4" according to the datasheet. 0x24 gives 100100 in bin enabling the
> 5th bit the IRQ slot and the timer 0. Once again thnx for all your
> time, about the URL that you send me in the example they are using FIQ
> but I got some understanding of that about the cycle mostly.
>
> Pedro Rodrigues
>
> --- In l...
,
"Paul
> Claessen" wrote:
> >
> > Get the sample 'LED blink through timer interrupt' program (See Timer
> > directory) here:
> >
> >
> >
> > http://tinyurl.com/2x2dfj
> >
> >
> >
> > ~ Paul Claessen
> >
> >
> >
> > From: l...

> [mailto:l...
] On
> Behalf Of
> > nimster6969
> > Sent: Friday, May 02, 2008 1:34 PM
> > To: l...

> > Subject: [lpc2000] Re: Problem with Timers and VICVectors on
CrossWorks.
> >
> >
> >
> > Yeah I know :( its very hard to get those books here in Portugal, I
> > dont want anyone to do the work for me, that way I'll never
> > learn...I've changed my code to:
> >
> > //Init Timers
> > T0TC = 0;
> > T0PR = 0x03; // Load prescaler for 5Ms on Timer
> > T0TCR = 0x02; // Reset timer and prescaler
> > T0MCR = 0x3; // MCR Config
> > T0MR0 = 0xB98C; // Get to 47500
> > T0TCR = 0x1; // Enable timer
> >
> > //Init VIC Vectors
> > VICVectAddr0=(unsigned)led_blink; // Set the timer ISR vector address
> > VICVectCntl0 = 0x24; // Set channel 0 and source #4
> > VICIntEnable = 0x00000010; // Enable the interrupt
> > __ARMLIB_enableIRQ();
> > }
> > //----------------------
> > //Program
> > //----------------------
> >
> > void led_blink(void)
> > {
> > debug_printf("Working");
> > T0IR = 0x01; // Clear time of interrupt
> > VICVectAddr = 0xFF; // Dummy write to signal end of interrupt
> > }
> >
> > int main()
> > {
> > Init();
> > }
> >
> > I've done the debug_printf to test if the interrupt is working but is
> > not, i've done a step by step debug and the Init(); function works
> > well but it doesnt make the ISR instruction.
> > Sorry about those questions is cause in my university people are
> > supose to choose some projects and do them with a uC teachers help
> > mostly with PIC and ARV and I've choosed to work on ARM on my own so
> > every thing that I made its really me and its from the things i've
> > read not with help of anyone, I know its small things but its a
> > beginning, I've made a party only for putting leds blinking with delay
> > :). Well once again thax for all the help, will try to get those books
> > online.
> >
> > --- In l...

> ,
> "Paul
> > Claessen" wrote:
> > >
> > > rimster6969,
> > >
> > > You really do need at least some basic knowledge before you start
> > programming embedded systems.
> > > If you don't understand basic concepts like interrupts (and let's be
> > brutally honest here: you don't), you are not going to get very far.
> > > Having us write your programs isn't going to teach you much.
> > > Begin with reading some basic embedded programming books.
> > > I can recommend: Programming Embedded Systems, by Michael Barr &
> > Anthony Massa (O'Reilly)
> > > and Designing Embedded Hardware by John Catsoulis (O'Reilly)
> > >
> > > As for your program, follow mjames_doveridge's advice below.
> > > You may want to consider reprogramming the timer in the main 'while'
> > loop, based on a flag that you set in your ISR, just to get used to
> > the idea to keep your ISR as short and sweet as possible.
> > >
> > > As for your question:
> > > "about the other question is it possible to read the TC value so I
> > can count how many cycles have been made? "
> > >
> > > Yes, you can read it. This is basic information available from any
> > decent datasheet or manual.
> > > But why read TC? It will be zero!
> > > You want to wait, say, 1000 pclk cycles. So you program the timer
> > with that. Your timer goes off when it reaches 0.
> > > So guess how many cycles have been made!
> > >
> > > ~ Paul Claessen
> > >
> > >
> > > ----- Original Message -----
> > > From: mjames_doveridge
> > > To: l...

>
> > > Sent: Friday, May 02, 2008 1:05 AM
> > > Subject: [lpc2000] Re: Problem with Timers and VICVectors on
> CrossWorks.
> > >
> > >
> > > --- In l...

> ,
> > "nimster6969" wrote:
> > > >
> > > > I've put my main like this, is that ok? Where do i need to
reprogram
> > > > the timers? Thnx
> > > >
> > > > int main()
> > > > {
> > > > Init();
> > > > led_blink();
> > > > }
> > > >
> > > >
> > >
> > > Like Paul said, why are you calling the interrupt handler
continually
> > > in main()? That just kills the interrupt and lights your LED at
> > > half-brightness as the uC flashes it at full speed.
> > >
> > > Keep the while loop. Keep the init and get rid of the explicit call
> > > to the handler.
> > >
> > > int main()
> > > {
> > > Init();
> > > while (1)
> > > {
> > > // led_blink();
> > > }
> > > }
> > >
> > > If you want to reprogram the timer, do it in the interrupt handler
> > > after swapping the LED state.
> > >
> > > Once you understand interrupts, you will be able to progress.
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> >
> >
> >
> >
> >
> >
> >
>