EmbeddedRelated.com
Forums

Problem with Timers and VICVectors on CrossWorks.

Started by nimster6969 May 1, 2008
I'm trying to make a led blink using interrupts and timers, already
did with delay but now I need to be able to control the times. I'm
using crossworks in my university and im able to copile this and build
the *.hex but it seems the interruption never happend neither in debug
mode.Is there anything wrong with my code...any mistake that I've
made, I'm using LPC2103 board and I'm a newbie in ARM7 but already
read the datasheet and some books and stuff in crossworks but cant
find the answer thats why im posting. Another question that I have is
how can I read the timer value "TC" in this case "T0TC" when a cycle
(PR+1) occurs the counter goes +1 is it possible to read this
value...how many cycles have been made? Thnx for all the help...below
is my full code: Best regards to all.

#include
#include
#define PLOCK 0x0400

static void led_blink(void)__attribute__((interrupt("IRQ")));

//---------------------
// System initializations
//---------------------

void Init()
{
// Init PLL
PLLCFG = 0x22;
// P=2, M=3, PLLfreq = 228 Mhz, CCLK = 57 Mhz
PLLFEED = 0xAA; PLLFEED =0x55;
PLLCON = 0x1;
// Enable the PLL
PLLFEED = 0xAA; PLLFEED =0x55;
while(!(PLLSTAT & PLOCK));
// Wait for PLL to lock
PLLCON = 0x3;
// Connect PLL as clock source
PLLFEED = 0xAA; PLLFEED =0x55;

//Init MAM & Flash memory fetch
MAMCR = 0x2; // mam = flash
MAMTIM = 0x4;
VPBDIV = 0x2; // pclk = cclk/2= 28,5Mhz

//GPIO init
IODIR = 0x00000080; // P0.7 is output(LED)
IOSET = 0x00000080;

//Init Timers
T0PR = 0x03;
// Load prescaler for 5Ms on Timer
T0TCR = 0x02;
// Reset timer and prescaler
T0MCR = 0x3;
// Configurao do MCR
T0MR0 = 0xB98C;
// Get to 47500 position
T0TCR = 0x1;
// Enable timer

//Init VIC Vectors
libarm_enable_irq(); //Don't know if this is needed
VICVectAddr0 = (unsigned)led_blink;
// Set the timer ISR vector address
VICVectCntl0 = 0x24;
// Set channel 0 and source #4
VICIntEnable = 0x00000010;
// Enable the interrupt

}
//-----------------------
//Program
//-----------------------

static void led_blink(void)
{
IOSET =~ IOSET;
T0IR = 0x01; // Clear time of interrupt
VICVectAddr = 0xFF; // Dummy write to signal end of interrupt
}


int main()
{
Init();
while (1)
{
led_blink();
}
}

An Engineer's Guide to the LPC2100 Series

Youre calling your own ISR constantly in your main loop! (which resets
interrupts!)

Dont do that.

Also, you have to reprogram your timer, once it goes off.



~ Paul Claessen



From: l... [mailto:l...] On Behalf Of
nimster6969
Sent: Thursday, May 01, 2008 9:34 AM
To: l...
Subject: [lpc2000] Problem with Timers and VICVectors on CrossWorks.



I'm trying to make a led blink using interrupts and timers, already
did with delay but now I need to be able to control the times. I'm
using crossworks in my university and im able to copile this and build
the *.hex but it seems the interruption never happend neither in debug
mode.Is there anything wrong with my code...any mistake that I've
made, I'm using LPC2103 board and I'm a newbie in ARM7 but already
read the datasheet and some books and stuff in crossworks but cant
find the answer thats why im posting. Another question that I have is
how can I read the timer value "TC" in this case "T0TC" when a cycle
(PR+1) occurs the counter goes +1 is it possible to read this
value...how many cycles have been made? Thnx for all the help...below
is my full code: Best regards to all.

#include
#include

#define PLOCK 0x0400

static void led_blink(void)__attribute__((interrupt("IRQ")));

//---------------------
// System initializations
//---------------------

void Init()
{
// Init PLL
PLLCFG = 0x22;
// P=2, M=3, PLLfreq = 228 Mhz, CCLK = 57 Mhz
PLLFEED = 0xAA; PLLFEED =0x55;
PLLCON = 0x1;
// Enable the PLL
PLLFEED = 0xAA; PLLFEED =0x55;
while(!(PLLSTAT & PLOCK));
// Wait for PLL to lock
PLLCON = 0x3;
// Connect PLL as clock source
PLLFEED = 0xAA; PLLFEED =0x55;

//Init MAM & Flash memory fetch
MAMCR = 0x2; // mam = flash
MAMTIM = 0x4;
VPBDIV = 0x2; // pclk = cclk/2= 28,5Mhz

//GPIO init
IODIR = 0x00000080; // P0.7 is output(LED)
IOSET = 0x00000080;

//Init Timers
T0PR = 0x03;
// Load prescaler for 5Ms on Timer
T0TCR = 0x02;
// Reset timer and prescaler
T0MCR = 0x3;
// Configurao do MCR
T0MR0 = 0xB98C;
// Get to 47500 position
T0TCR = 0x1;
// Enable timer

//Init VIC Vectors
libarm_enable_irq(); //Don't know if this is needed
VICVectAddr0 = (unsigned)led_blink;
// Set the timer ISR vector address
VICVectCntl0 = 0x24;
// Set channel 0 and source #4
VICIntEnable = 0x00000010;
// Enable the interrupt

}
//----------------------
//Program
//----------------------

static void led_blink(void)
{
IOSET =~ IOSET;
T0IR = 0x01; // Clear time of interrupt
VICVectAddr = 0xFF; // Dummy write to signal end of interrupt
}

int main()
{
Init();
while (1)
{
led_blink();
}
}




Sorry but I didnt understand...you saying that I need to remove the
while(1) from the main function so the interrupt don't repeat? Only
the inicialization is in the Init function wich is used by the while
cycle. How do I reprogram the timer once it goes off? Sorry about
those questions has I said Im new to ARM7 and trying hard to
learning...about the other question is it possible to read the TC
value so I can count how many cycles have been made? Thanx

--- In l..., "Paul Claessen" wrote:
>
> You're calling your own ISR constantly in your main loop! (which resets
> interrupts!)
>
> Don't do that.
>
> Also, you have to reprogram your timer, once it goes off.
>
>
>
> ~ Paul Claessen
>
>
>
> From: l... [mailto:l...] On
Behalf Of
> nimster6969
> Sent: Thursday, May 01, 2008 9:34 AM
> To: l...
> Subject: [lpc2000] Problem with Timers and VICVectors on CrossWorks.
>
>
>
> I'm trying to make a led blink using interrupts and timers, already
> did with delay but now I need to be able to control the times. I'm
> using crossworks in my university and im able to copile this and build
> the *.hex but it seems the interruption never happend neither in debug
> mode.Is there anything wrong with my code...any mistake that I've
> made, I'm using LPC2103 board and I'm a newbie in ARM7 but already
> read the datasheet and some books and stuff in crossworks but cant
> find the answer thats why im posting. Another question that I have is
> how can I read the timer value "TC" in this case "T0TC" when a cycle
> (PR+1) occurs the counter goes +1 is it possible to read this
> value...how many cycles have been made? Thnx for all the help...below
> is my full code: Best regards to all.
>
> #include
> #include
>
> #define PLOCK 0x0400
>
> static void led_blink(void)__attribute__((interrupt("IRQ")));
>
> //---------------------
> // System initializations
> //---------------------
>
> void Init()
> {
> // Init PLL
> PLLCFG = 0x22;
> // P=2, M=3, PLLfreq = 228 Mhz, CCLK = 57 Mhz
> PLLFEED = 0xAA; PLLFEED =0x55;
> PLLCON = 0x1;
> // Enable the PLL
> PLLFEED = 0xAA; PLLFEED =0x55;
> while(!(PLLSTAT & PLOCK));
> // Wait for PLL to lock
> PLLCON = 0x3;
> // Connect PLL as clock source
> PLLFEED = 0xAA; PLLFEED =0x55;
>
> //Init MAM & Flash memory fetch
> MAMCR = 0x2; // mam = flash
> MAMTIM = 0x4;
> VPBDIV = 0x2; // pclk = cclk/2= 28,5Mhz
>
> //GPIO init
> IODIR = 0x00000080; // P0.7 is output(LED)
> IOSET = 0x00000080;
>
> //Init Timers
> T0PR = 0x03;
> // Load prescaler for 5Ms on Timer
> T0TCR = 0x02;
> // Reset timer and prescaler
> T0MCR = 0x3;
> // Configurao do MCR
> T0MR0 = 0xB98C;
> // Get to 47500 position
> T0TCR = 0x1;
> // Enable timer
>
> //Init VIC Vectors
> libarm_enable_irq(); //Don't know if this is needed
> VICVectAddr0 = (unsigned)led_blink;
> // Set the timer ISR vector address
> VICVectCntl0 = 0x24;
> // Set channel 0 and source #4
> VICIntEnable = 0x00000010;
> // Enable the interrupt
>
> }
> //----------------------
> //Program
> //----------------------
>
> static void led_blink(void)
> {
> IOSET =~ IOSET;
> T0IR = 0x01; // Clear time of interrupt
> VICVectAddr = 0xFF; // Dummy write to signal end of interrupt
> }
>
> int main()
> {
> Init();
> while (1)
> {
> led_blink();
> }
> }
>
>
>
>
>
>
>

I've put my main like this, is that ok? Where do i need to reprogram
the timers? Thnx

int main()
{
Init();
led_blink();
}
--- In l..., "Paul Claessen" wrote:
>
> You're calling your own ISR constantly in your main loop! (which resets
> interrupts!)
>
> Don't do that.
>
> Also, you have to reprogram your timer, once it goes off.
>
>
>
> ~ Paul Claessen
>
>
>
> From: l... [mailto:l...] On
Behalf Of
> nimster6969
> Sent: Thursday, May 01, 2008 9:34 AM
> To: l...
> Subject: [lpc2000] Problem with Timers and VICVectors on CrossWorks.
>
>
>
> I'm trying to make a led blink using interrupts and timers, already
> did with delay but now I need to be able to control the times. I'm
> using crossworks in my university and im able to copile this and build
> the *.hex but it seems the interruption never happend neither in debug
> mode.Is there anything wrong with my code...any mistake that I've
> made, I'm using LPC2103 board and I'm a newbie in ARM7 but already
> read the datasheet and some books and stuff in crossworks but cant
> find the answer thats why im posting. Another question that I have is
> how can I read the timer value "TC" in this case "T0TC" when a cycle
> (PR+1) occurs the counter goes +1 is it possible to read this
> value...how many cycles have been made? Thnx for all the help...below
> is my full code: Best regards to all.
>
> #include
> #include
>
> #define PLOCK 0x0400
>
> static void led_blink(void)__attribute__((interrupt("IRQ")));
>
> //---------------------
> // System initializations
> //---------------------
>
> void Init()
> {
> // Init PLL
> PLLCFG = 0x22;
> // P=2, M=3, PLLfreq = 228 Mhz, CCLK = 57 Mhz
> PLLFEED = 0xAA; PLLFEED =0x55;
> PLLCON = 0x1;
> // Enable the PLL
> PLLFEED = 0xAA; PLLFEED =0x55;
> while(!(PLLSTAT & PLOCK));
> // Wait for PLL to lock
> PLLCON = 0x3;
> // Connect PLL as clock source
> PLLFEED = 0xAA; PLLFEED =0x55;
>
> //Init MAM & Flash memory fetch
> MAMCR = 0x2; // mam = flash
> MAMTIM = 0x4;
> VPBDIV = 0x2; // pclk = cclk/2= 28,5Mhz
>
> //GPIO init
> IODIR = 0x00000080; // P0.7 is output(LED)
> IOSET = 0x00000080;
>
> //Init Timers
> T0PR = 0x03;
> // Load prescaler for 5Ms on Timer
> T0TCR = 0x02;
> // Reset timer and prescaler
> T0MCR = 0x3;
> // Configurao do MCR
> T0MR0 = 0xB98C;
> // Get to 47500 position
> T0TCR = 0x1;
> // Enable timer
>
> //Init VIC Vectors
> libarm_enable_irq(); //Don't know if this is needed
> VICVectAddr0 = (unsigned)led_blink;
> // Set the timer ISR vector address
> VICVectCntl0 = 0x24;
> // Set channel 0 and source #4
> VICIntEnable = 0x00000010;
> // Enable the interrupt
>
> }
> //----------------------
> //Program
> //----------------------
>
> static void led_blink(void)
> {
> IOSET =~ IOSET;
> T0IR = 0x01; // Clear time of interrupt
> VICVectAddr = 0xFF; // Dummy write to signal end of interrupt
> }
>
> int main()
> {
> Init();
> while (1)
> {
> led_blink();
> }
> }
>
>
>
>
>
>
>

--- 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.

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.


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.
>
>
>
>
>

First of all, your program exits (ends) right after the init call in main.
That's not what you want.

Put a while(1)l; after that init() call (THAT part was okay, just not
calling led_blink() yourself!)

Also the timer doesn't go to VICVectAddr0, I think it goes to VICVectAddr4:
double check that in your uC's manual.

(Same forVICVect Cntl)

~ 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.
>
>
>


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.
>
>
>


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.
> >
> >
> >
> >
> >
> >
> >
>
>
>