Reply by redwire85 December 1, 20092009-12-01
You don't want that...so try clearing it before entering the infinite loop. :)

--- In l..., "kay_niv" wrote:
> i am debugging using jtag ,i can see that the I bit of cpsr is set while in the infinite loop .
>
> --- In l..., "redwire85" wrote:
> >
> > Did you check the "I" bit in the CPU control register. It will mask all interrupts...
> >
> > Some startup code clears the I bit before turning control over to main. Others do not...
> >
> >
> > --- In l..., "kay_niv" wrote:
> > >
> > >
> > > i'm a novice learning about ARM using lpc2148.i'm not able to get into the isr,the code compiles perfectly and even the VIC registers are all set(the address of isr),timer works in polling mode but i'm not able to setup properly the interrupt.i'm using Crossworks 1.7.please help with this,i'm stuck here.
> > >
> > >
> > > **********************************************************************
> > > #include "lpc_2148.h"
> > > #include "lpc_vic.h"
> > >
> > > volatile int toggle=0;
> > > void init_timer0(void);
> > > static void t0isr(void) __attribute__ ((interrupt("IRQ")));
> > >
> > > int main(void)
> > > {
> > > IO1DIR |= 0x02000000; // Output for buzzer
> > >
> > > init_timer0();
> > >
> > > while(1)
> > > {
> > > if(toggle != 0)
> > > IO1CLR= 0x02000000;
> > > else
> > > IO1SET= 0x02000000;
> > > }
> > >
> > > }
> > > void init_timer0(void)
> > > {
> > > //--- Timer 0 - interrupt 10 ms
> > >
> > >
> > >
> > > T0PR = 5; //-- Prescaler = 0
> > > T0PC = 0; // Prescaler Counter
> > > //T0MR0 = 60000 * 10; //clock rate of 60000 * 10ms ?
> > > T0MR0 = 2 ; // 1ms
> > > T0MCR = 2; //-- bit 0=1 -int on MR0 , bit 1=1 - Reset on MR0
> > > T0TCR = 1; //-- Timer 0 - run
> > >
> > > VICIntSelect &= ~ VIC_BIT(VIC_TIMER0);
> > > VICVectAddr0 = (unsigned int)t0isr;//-- Timer 0 int - prioritytop-1
> > > VICVectCntl0 = VIC_ENABLE | VIC_TIMER0;
> > > VICIntEnable |= VIC_BIT(VIC_TIMER0);
> > >
> > > }
> > >
> > > static void t0isr(void)
> > > {
> > > T0IR=0xFF;
> > > toggle=~toggle; //is this correct
> > > VICVectAddr = 0xFF;
> > > }
> > > ********************************************************************
> > >
>

An Engineer's Guide to the LPC2100 Series

Reply by rtstofer December 1, 20092009-12-01
--- In l..., vinayak hungund wrote:
>
> guys the problem is *i'm not hitting the ISR* ! as far as using ctl ,why is
> there any need if u yourself setup the VICs.thank you guys for your time..
>
If you, yourself, are handling the VIC, you need to be certain that interrupts are enabled in CPSR. I haven't looked at the Crossworks startup code so I don't know how it's handled.

For GNUARM (GCC), we have to add a line in crt.s (or whatever it is called) before the branch to 'main' like:

MSR CPSR_c,#MODE_SVC /* enable interrupts */
b main

You need to fix that ~toggle statement to something like:

toggle = ~toggle;

You still might want to look at CTL because it may already allow nested interrupts. But, for certain, you have to add some more (assembly) code if you want nested interrupts with GNUARM.

Richard

Reply by kay_niv December 1, 20092009-12-01
i am debugging using jtag ,i can see that the I bit of cpsr is set while in the infinite loop .

--- In l..., "redwire85" wrote:
>
> Did you check the "I" bit in the CPU control register. It will mask all interrupts...
>
> Some startup code clears the I bit before turning control over to main. Others do not...
> --- In l..., "kay_niv" wrote:
> >
> >
> > i'm a novice learning about ARM using lpc2148.i'm not able to get into the isr,the code compiles perfectly and even the VIC registers are all set(the address of isr),timer works in polling mode but i'm not able to setup properly the interrupt.i'm using Crossworks 1.7.please help with this,i'm stuck here.
> >
> >
> > **********************************************************************
> > #include "lpc_2148.h"
> > #include "lpc_vic.h"
> >
> > volatile int toggle=0;
> > void init_timer0(void);
> > static void t0isr(void) __attribute__ ((interrupt("IRQ")));
> >
> > int main(void)
> > {
> > IO1DIR |= 0x02000000; // Output for buzzer
> >
> > init_timer0();
> >
> > while(1)
> > {
> > if(toggle != 0)
> > IO1CLR= 0x02000000;
> > else
> > IO1SET= 0x02000000;
> > }
> >
> > }
> > void init_timer0(void)
> > {
> > //--- Timer 0 - interrupt 10 ms
> >
> >
> >
> > T0PR = 5; //-- Prescaler = 0
> > T0PC = 0; // Prescaler Counter
> > //T0MR0 = 60000 * 10; //clock rate of 60000 * 10ms ?
> > T0MR0 = 2 ; // 1ms
> > T0MCR = 2; //-- bit 0=1 -int on MR0 , bit 1=1 - Reset on MR0
> > T0TCR = 1; //-- Timer 0 - run
> >
> > VICIntSelect &= ~ VIC_BIT(VIC_TIMER0);
> > VICVectAddr0 = (unsigned int)t0isr;//-- Timer 0 int - prioritytop-1
> > VICVectCntl0 = VIC_ENABLE | VIC_TIMER0;
> > VICIntEnable |= VIC_BIT(VIC_TIMER0);
> >
> > }
> >
> > static void t0isr(void)
> > {
> > T0IR=0xFF;
> > toggle=~toggle; //is this correct
> > VICVectAddr = 0xFF;
> > }
> > ********************************************************************
>

Reply by redwire85 December 1, 20092009-12-01
Did you check the "I" bit in the CPU control register. It will mask all interrupts...

Some startup code clears the I bit before turning control over to main. Others do not...
--- In l..., "kay_niv" wrote:
> i'm a novice learning about ARM using lpc2148.i'm not able to get into the isr,the code compiles perfectly and even the VIC registers are all set(the address of isr),timer works in polling mode but i'm not able to setup properly the interrupt.i'm using Crossworks 1.7.please help with this,i'm stuck here.
> **********************************************************************
> #include "lpc_2148.h"
> #include "lpc_vic.h"
>
> volatile int toggle=0;
> void init_timer0(void);
> static void t0isr(void) __attribute__ ((interrupt("IRQ")));
>
> int main(void)
> {
> IO1DIR |= 0x02000000; // Output for buzzer
>
> init_timer0();
>
> while(1)
> {
> if(toggle != 0)
> IO1CLR= 0x02000000;
> else
> IO1SET= 0x02000000;
> }
>
> }
> void init_timer0(void)
> {
> //--- Timer 0 - interrupt 10 ms
>
>
>
> T0PR = 5; //-- Prescaler = 0
> T0PC = 0; // Prescaler Counter
> //T0MR0 = 60000 * 10; //clock rate of 60000 * 10ms ?
> T0MR0 = 2 ; // 1ms
> T0MCR = 2; //-- bit 0=1 -int on MR0 , bit 1=1 - Reset on MR0
> T0TCR = 1; //-- Timer 0 - run
>
> VICIntSelect &= ~ VIC_BIT(VIC_TIMER0);
> VICVectAddr0 = (unsigned int)t0isr;//-- Timer 0 int - prioritytop-1
> VICVectCntl0 = VIC_ENABLE | VIC_TIMER0;
> VICIntEnable |= VIC_BIT(VIC_TIMER0);
>
> }
>
> static void t0isr(void)
> {
> T0IR=0xFF;
> ~toggle;
> VICVectAddr = 0xFF;
> }
> ********************************************************************
>

Reply by vinayak hungund December 1, 20092009-12-01
guys the problem is *i'm not hitting the ISR* ! as far as using ctl ,why is
there any need if u yourself setup the VICs.thank you guys for your time..

On Tue, Dec 1, 2009 at 3:47 AM, Was wrote:

> I'm new here(arm/lpc/etc.), but not to c.
>
> I don't think that the line "~toggle;" in your t0isr() actually does
> anything.
>
> For example, this code produces this output:
>
> 16:10:01 ~/bin
> > cat notnot.c
> volatile int toggle=0;
>
> int main(void)
> {
> printf(" toggle=%d\n", toggle);
> ~toggle;
> printf(" toggle=%d\n", toggle);
> }
>
> 16:10:12 ~/bin
> > gcc notnot.c -o notnot
>
> 16:10:15 ~/bin
> > ./notnot
> toggle=0
> toggle=0
> --- In l... , "kay_niv"
> wrote:
> >
> >
> > i'm a novice learning about ARM using lpc2148.i'm not able to get into
> the isr,the code compiles perfectly and even the VIC registers are all
> set(the address of isr),timer works in polling mode but i'm not able to
> setup properly the interrupt.i'm using Crossworks 1.7.please help with
> this,i'm stuck here.
> >
> >
> > **********************************************************************
> > #include "lpc_2148.h"
> > #include "lpc_vic.h"
> >
> > volatile int toggle=0;
> > void init_timer0(void);
> > static void t0isr(void) __attribute__ ((interrupt("IRQ")));
> >
> > int main(void)
> > {
> > IO1DIR |= 0x02000000; // Output for buzzer
> >
> > init_timer0();
> >
> > while(1)
> > {
> > if(toggle != 0)
> > IO1CLR= 0x02000000;
> > else
> > IO1SET= 0x02000000;
> > }
> >
> > }
> > void init_timer0(void)
> > {
> > //--- Timer 0 - interrupt 10 ms
> >
> >
> >
> > T0PR = 5; //-- Prescaler = 0
> > T0PC = 0; // Prescaler Counter
> > //T0MR0 = 60000 * 10; //clock rate of 60000 * 10ms ?
> > T0MR0 = 2 ; // 1ms
> > T0MCR = 2; //-- bit 0=1 -int on MR0 , bit 1=1 - Reset on MR0
> > T0TCR = 1; //-- Timer 0 - run
> >
> > VICIntSelect &= ~ VIC_BIT(VIC_TIMER0);
> > VICVectAddr0 = (unsigned int)t0isr;//-- Timer 0 int - prioritytop-1
> > VICVectCntl0 = VIC_ENABLE | VIC_TIMER0;
> > VICIntEnable |= VIC_BIT(VIC_TIMER0);
> >
> > }
> >
> > static void t0isr(void)
> > {
> > T0IR=0xFF;
> > ~toggle;
> > VICVectAddr = 0xFF;
> > }
> > ********************************************************************
> >
>
Reply by Was November 30, 20092009-11-30
I'm new here(arm/lpc/etc.), but not to c.

I don't think that the line "~toggle;" in your t0isr() actually does anything.

For example, this code produces this output:

16:10:01 ~/bin
> cat notnot.c
volatile int toggle=0;

int main(void)
{
printf(" toggle=%d\n", toggle);
~toggle;
printf(" toggle=%d\n", toggle);
}

16:10:12 ~/bin
> gcc notnot.c -o notnot

16:10:15 ~/bin
> ./notnot
toggle=0
toggle=0

--- In l..., "kay_niv" wrote:
> i'm a novice learning about ARM using lpc2148.i'm not able to get into the isr,the code compiles perfectly and even the VIC registers are all set(the address of isr),timer works in polling mode but i'm not able to setup properly the interrupt.i'm using Crossworks 1.7.please help with this,i'm stuck here.
> **********************************************************************
> #include "lpc_2148.h"
> #include "lpc_vic.h"
>
> volatile int toggle=0;
> void init_timer0(void);
> static void t0isr(void) __attribute__ ((interrupt("IRQ")));
>
> int main(void)
> {
> IO1DIR |= 0x02000000; // Output for buzzer
>
> init_timer0();
>
> while(1)
> {
> if(toggle != 0)
> IO1CLR= 0x02000000;
> else
> IO1SET= 0x02000000;
> }
>
> }
> void init_timer0(void)
> {
> //--- Timer 0 - interrupt 10 ms
>
>
>
> T0PR = 5; //-- Prescaler = 0
> T0PC = 0; // Prescaler Counter
> //T0MR0 = 60000 * 10; //clock rate of 60000 * 10ms ?
> T0MR0 = 2 ; // 1ms
> T0MCR = 2; //-- bit 0=1 -int on MR0 , bit 1=1 - Reset on MR0
> T0TCR = 1; //-- Timer 0 - run
>
> VICIntSelect &= ~ VIC_BIT(VIC_TIMER0);
> VICVectAddr0 = (unsigned int)t0isr;//-- Timer 0 int - prioritytop-1
> VICVectCntl0 = VIC_ENABLE | VIC_TIMER0;
> VICIntEnable |= VIC_BIT(VIC_TIMER0);
>
> }
>
> static void t0isr(void)
> {
> T0IR=0xFF;
> ~toggle;
> VICVectAddr = 0xFF;
> }
> ********************************************************************
>

Reply by leon Heller November 30, 20092009-11-30
----- Original Message -----
From: "kay_niv"
To:
Sent: Monday, November 30, 2009 9:27 PM
Subject: [lpc2000] Timer 0 Interrupt in crossworks
>
> i'm a novice learning about ARM using lpc2148.i'm not able to get into the
> isr,the code compiles perfectly and even the VIC registers are all set(the
> address of isr),timer works in polling mode but i'm not able to setup
> properly the interrupt.i'm using Crossworks 1.7.please help with this,i'm
> stuck here.

I use CTL for timer interrupts, it makes things much easier.

Leon

Reply by kay_niv November 30, 20092009-11-30
i'm a novice learning about ARM using lpc2148.i'm not able to get into the isr,the code compiles perfectly and even the VIC registers are all set(the address of isr),timer works in polling mode but i'm not able to setup properly the interrupt.i'm using Crossworks 1.7.please help with this,i'm stuck here.
**********************************************************************
#include "lpc_2148.h"
#include "lpc_vic.h"

volatile int toggle=0;
void init_timer0(void);
static void t0isr(void) __attribute__ ((interrupt("IRQ")));

int main(void)
{
IO1DIR |= 0x02000000; // Output for buzzer

init_timer0();

while(1)
{
if(toggle != 0)
IO1CLR= 0x02000000;
else
IO1SET= 0x02000000;
}

}
void init_timer0(void)
{
//--- Timer 0 - interrupt 10 ms

T0PR = 5; //-- Prescaler = 0
T0PC = 0; // Prescaler Counter
//T0MR0 = 60000 * 10; //clock rate of 60000 * 10ms ?
T0MR0 = 2 ; // 1ms
T0MCR = 2; //-- bit 0=1 -int on MR0 , bit 1=1 - Reset on MR0
T0TCR = 1; //-- Timer 0 - run

VICIntSelect &= ~ VIC_BIT(VIC_TIMER0);
VICVectAddr0 = (unsigned int)t0isr;//-- Timer 0 int - prioritytop-1
VICVectCntl0 = VIC_ENABLE | VIC_TIMER0;
VICIntEnable |= VIC_BIT(VIC_TIMER0);

}

static void t0isr(void)
{
T0IR=0xFF;
~toggle;
VICVectAddr = 0xFF;
}
********************************************************************