EmbeddedRelated.com
Forums

unable to run the interrupt handler

Started by preethamreddy1989 October 4, 2012
hello friends unable to run the interrupt so plz frirends cuns u send me some sample codes to run the interrupt
#include

void RTC_isr(void)
{
/* write code here */
if(ILR&0x01)
{
IOSET1=0xf0000000;
}
if(ILR&0x03)
{
IOSET1=0x0f000000;
}
/* list of all available flags, select which to use */
ILR = (1UL<<0); /* Clear RTC counter increment interrupt flag */
ILR = (1UL<<1); /* Clear RTC alarm interrupt flag */
VICVectAddr = 0; /* Acknowledge Interrupt */
}

/* Default Interrupt Function: may be called when ISR is disabled */
void DefISR (void) {
}

int main()
{
VPBDIV=0x02;
IODIR1 = 0xFFFF0000;
// Set LED ports to output
IOSET1 = 0x00020000;
PREINT = 0x00000392;
// Set RTC prescaler for 12.000Mhz Xtal
PREFRAC = 0x00004380;
CCR = 0x01;
SEC = 0;
MIN = 0;
HOUR= 0;
CIIR = 0x01;
MAMCR=0x02;
MAMTIM=0x04;

ALSEC=0x03;
AMR=0x0FE;
ILR=0x01; // Interupt every second

VICVectAddr1 = (unsigned ) RTC_isr; /* set interrupt vector 1 */
VICVectCntl1 = ( 0x20 | 13 ); /* enable slot & use it for RTC Interrupt */
VICIntEnable |= (1UL<<13); /* Enable RTC Interrupt */

VICDefVectAddr = (unsigned ) DefISR; /* un-assigned VIC interrupts */

while(1)
{

}
}

An Engineer's Guide to the LPC2100 Series

On 4/10/2012 18:56, preethamreddy1989 wrote:
>
> hello friends unable to run the interrupt so plz frirends cuns u send me some sample codes to run the interrupt
> #include void RTC_isr(void)
> {
> /* write code here */
> if(ILR&0x01)
> {
> IOSET1=0xf0000000;
> }
> if(ILR&0x03)
> {
> IOSET1=0x0f000000;
> }
> /* list of all available flags, select which to use */
> ILR = (1UL<<0); /* Clear RTC counter increment interrupt flag */
> ILR = (1UL<<1); /* Clear RTC alarm interrupt flag */
> VICVectAddr = 0; /* Acknowledge Interrupt */
> }
>
> /* Default Interrupt Function: may be called when ISR is disabled */
> void DefISR (void) {
> }
>
> int main()
> {
> VPBDIV=0x02;
> IODIR1 = 0xFFFF0000;
> // Set LED ports to output
> IOSET1 = 0x00020000;
> PREINT = 0x00000392;
> // Set RTC prescaler for 12.000Mhz Xtal
> PREFRAC = 0x00004380;
> CCR = 0x01;
> SEC = 0;
> MIN = 0;
> HOUR= 0;
> CIIR = 0x01;
> MAMCR=0x02;
> MAMTIM=0x04;
>
> ALSEC=0x03;
> AMR=0x0FE;
> ILR=0x01; // Interupt every second
>
> VICVectAddr1 = (unsigned ) RTC_isr; /* set interrupt vector 1 */
> VICVectCntl1 = ( 0x20 | 13 ); /* enable slot & use it for RTC Interrupt */
> VICIntEnable |= (1UL<<13); /* Enable RTC Interrupt */
>
> VICDefVectAddr = (unsigned ) DefISR; /* un-assigned VIC interrupts */
>
> while(1)
> {
> }
> }
I have tried your code in Uvision simulator with LPC2114 and the interrupt is called and executed so what is the problem?
Maybe a hardware problem with the RTC?

Alex
---------------------
http://alexan.edaboard.eu/ (Home of ARMwizard, a free tool for peripheral initialization of LPC2xxx/17xx/13xx/11xx/122x microcontrollers )



--- In l..., Alexan_e wrote:
>
> On 4/10/2012 18:56, preethamreddy1989 wrote:
> >
> > hello friends unable to run the interrupt so plz frirends cuns u send me some sample codes to run the interrupt
> > #include
> >
> > void RTC_isr(void)
> > {
> > /* write code here */
> > if(ILR&0x01)
> > {
> > IOSET1=0xf0000000;
> > }
> > if(ILR&0x03)
> > {
> > IOSET1=0x0f000000;
> > }
> > /* list of all available flags, select which to use */
> > ILR = (1UL<<0); /* Clear RTC counter increment interrupt flag */
> > ILR = (1UL<<1); /* Clear RTC alarm interrupt flag */
> > VICVectAddr = 0; /* Acknowledge Interrupt */
> > }
> >
> > /* Default Interrupt Function: may be called when ISR is disabled */
> > void DefISR (void) {
> > }
> >
> > int main()
> > {
> > VPBDIV=0x02;
> > IODIR1 = 0xFFFF0000;
> > // Set LED ports to output
> > IOSET1 = 0x00020000;
> > PREINT = 0x00000392;
> > // Set RTC prescaler for 12.000Mhz Xtal
> > PREFRAC = 0x00004380;
> > CCR = 0x01;
> > SEC = 0;
> > MIN = 0;
> > HOUR= 0;
> > CIIR = 0x01;
> > MAMCR=0x02;
> > MAMTIM=0x04;
> >
> > ALSEC=0x03;
> > AMR=0x0FE;
> > ILR=0x01; // Interupt every second
> >
> > VICVectAddr1 = (unsigned ) RTC_isr; /* set interrupt vector 1 */
> > VICVectCntl1 = ( 0x20 | 13 ); /* enable slot & use it for RTC Interrupt */
> > VICIntEnable |= (1UL<<13); /* Enable RTC Interrupt */
> >
> > VICDefVectAddr = (unsigned ) DefISR; /* un-assigned VIC interrupts */
> >
> > while(1)
> > {
> >
> >
> > }
> > }
> >
> >
> I have tried your code in Uvision simulator with LPC2114 and the interrupt is called and executed so what is the problem?
> Maybe a hardware problem with the RTC?
>
> Alex
> ---------------------
> http://alexan.edaboard.eu/ (Home of ARMwizard, a free tool for peripheral initialization of LPC2xxx/17xx/13xx/11xx/122x microcontrollers )
>
>

when the interupt is callled the port bits are not set
thats the problem and can u send some example for real time clock programs or a tutorial for real time clock
i need a program for to run the clock and generate an interrupt for every 20 minuntes

--- In l..., "preethamreddy1989" wrote:
>
> --- In l..., Alexan_e wrote:
> >
> > On 4/10/2012 18:56, preethamreddy1989 wrote:
> > >
> > > hello friends unable to run the interrupt so plz frirends cuns u send me some sample codes to run the interrupt
> > > #include
> > >
> > > void RTC_isr(void)
> > > {
> > > /* write code here */
> > > if(ILR&0x01)
> > > {
> > > IOSET1=0xf0000000;
> > > }
> > > if(ILR&0x03)
> > > {
> > > IOSET1=0x0f000000;
> > > }
> > > /* list of all available flags, select which to use */
> > > ILR = (1UL<<0); /* Clear RTC counter increment interrupt flag */
> > > ILR = (1UL<<1); /* Clear RTC alarm interrupt flag */
> > > VICVectAddr = 0; /* Acknowledge Interrupt */
> > > }
> > >
> > > /* Default Interrupt Function: may be called when ISR is disabled */
> > > void DefISR (void) {
> > > }
> > >
> > > int main()
> > > {
> > > VPBDIV=0x02;
> > > IODIR1 = 0xFFFF0000;
> > > // Set LED ports to output
> > > IOSET1 = 0x00020000;
> > > PREINT = 0x00000392;
> > > // Set RTC prescaler for 12.000Mhz Xtal
> > > PREFRAC = 0x00004380;
> > > CCR = 0x01;
> > > SEC = 0;
> > > MIN = 0;
> > > HOUR= 0;
> > > CIIR = 0x01;
> > > MAMCR=0x02;
> > > MAMTIM=0x04;
> > >
> > > ALSEC=0x03;
> > > AMR=0x0FE;
> > > ILR=0x01; // Interupt every second
> > >
> > > VICVectAddr1 = (unsigned ) RTC_isr; /* set interrupt vector 1 */
> > > VICVectCntl1 = ( 0x20 | 13 ); /* enable slot & use it for RTC Interrupt */
> > > VICIntEnable |= (1UL<<13); /* Enable RTC Interrupt */
> > >
> > > VICDefVectAddr = (unsigned ) DefISR; /* un-assigned VIC interrupts */
> > >
> > > while(1)
> > > {
> > >
> > >
> > > }
> > > }
> > >
> > >
> >
> >
> > I have tried your code in Uvision simulator with LPC2114 and the interrupt is called and executed so what is the problem?
> > Maybe a hardware problem with the RTC?
> >
> > Alex
> > ---------------------
> > http://alexan.edaboard.eu/ (Home of ARMwizard, a free tool for peripheral initialization of LPC2xxx/17xx/13xx/11xx/122x microcontrollers )
> >
> >
> >
> >
>
> when the interupt is callled the port bits are not set
> thats the problem and can u send some example for real time clock programs or a tutorial for real time clock
> i need a program for to run the clock and generate an interrupt for every 20 minuntes
>i m using lpc2148 microcontroller

On Fri, 2012-10-05 at 03:35 +0000, preethamreddy1989 wrote:
> > > void RTC_isr(void)
> > > {
> > > /* write code here */
> > > if(ILR&0x01)
> > > {
> > > IOSET1=0xf0000000;
> > > }
> > > if(ILR&0x03)
> > > {
> > > IOSET1=0x0f000000;
> > > }

How about the use of ioclr1 to turn off the LEDs ?

roelof

On 10/05/2012 10:22 AM, roelof 't Hooft wrote:
>
> On Fri, 2012-10-05 at 03:35 +0000, preethamreddy1989 wrote:
> > > > void RTC_isr(void)
> > > > {
> > > > /* write code here */
> > > > if(ILR&0x01)
> > > > {
> > > > IOSET1=0xf0000000;
> > > > }
> > > > if(ILR&0x03)
> > > > {
> > > > IOSET1=0x0f000000;
> > > > }
>
> How about the use of ioclr1 to turn off the LEDs ?
>
> roelof

I just noticed that the interrupt function declaration is missing the
__isr prefix, it should be
__isr void RTC_isr(void)

Also both if(ILR&0x01) and if(ILR&0x03) are true every time the
interrupt fires (because IRL equals 1) so you should consider using
if(ILR&0x02) to check the alarm flag

Alex
---------------------
http://alexan.edaboard.eu/ (Home of ARMwizard, a free tool for peripheral initialization of LPC2xxx/17xx/13xx/11xx microcontrollers )

--- In l..., Alexan_e wrote:
>
> On 10/05/2012 10:22 AM, roelof 't Hooft wrote:
> >
> > On Fri, 2012-10-05 at 03:35 +0000, preethamreddy1989 wrote:
> > > > > void RTC_isr(void)
> > > > > {
> > > > > /* write code here */
> > > > > if(ILR&0x01)
> > > > > {
> > > > > IOSET1=0xf0000000;
> > > > > }
> > > > > if(ILR&0x03)
> > > > > {
> > > > > IOSET1=0x0f000000;
> > > > > }
> >
> > How about the use of ioclr1 to turn off the LEDs ?
> >
> > roelof
> >
> > I just noticed that the interrupt function declaration is missing the
> __isr prefix, it should be
> __isr void RTC_isr(void)
>
> Also both if(ILR&0x01) and if(ILR&0x03) are true every time the
> interrupt fires (because IRL equals 1) so you should consider using
> if(ILR&0x02) to check the alarm flag
>
> Alex
> ---------------------
> http://alexan.edaboard.eu/ (Home of ARMwizard, a free tool for peripheral initialization of LPC2xxx/17xx/13xx/11xx microcontrollers )
>

sorry i did not get can u reprogram that my program with interrupt genterating for every 20 min plz do this

--- In l..., Alexan_e wrote:
>
> On 10/05/2012 10:22 AM, roelof 't Hooft wrote:
> >
> > On Fri, 2012-10-05 at 03:35 +0000, preethamreddy1989 wrote:
> > > > > void RTC_isr(void)
> > > > > {
> > > > > /* write code here */
> > > > > if(ILR&0x01)
> > > > > {
> > > > > IOSET1=0xf0000000;
> > > > > }
> > > > > if(ILR&0x03)
> > > > > {
> > > > > IOSET1=0x0f000000;
> > > > > }
> >
> > How about the use of ioclr1 to turn off the LEDs ?
> >
> > roelof
> >
> > I just noticed that the interrupt function declaration is missing the
> __isr prefix, it should be
> __isr void RTC_isr(void)
>
> Also both if(ILR&0x01) and if(ILR&0x03) are true every time the
> interrupt fires (because IRL equals 1) so you should consider using
> if(ILR&0x02) to check the alarm flag
>
> Alex
> ---------------------
> http://alexan.edaboard.eu/ (Home of ARMwizard, a free tool for peripheral initialization of LPC2xxx/17xx/13xx/11xx microcontrollers )
>
im getting more error if a add __isr prefix

On 5/10/2012 17:23, preethamreddy1989 wrote:
>
> --- In l... , Alexan_e wrote:
> >
> > On 10/05/2012 10:22 AM, roelof 't Hooft wrote:
> > >
> > > On Fri, 2012-10-05 at 03:35 +0000, preethamreddy1989 wrote:
> > > > > > void RTC_isr(void)
> > > > > > {
> > > > > > /* write code here */
> > > > > > if(ILR&0x01)
> > > > > > {
> > > > > > IOSET1=0xf0000000;
> > > > > > }
> > > > > > if(ILR&0x03)
> > > > > > {
> > > > > > IOSET1=0x0f000000;
> > > > > > }
> > >
> > > How about the use of ioclr1 to turn off the LEDs ?
> > >
> > > roelof
> > >
> > >
> >
> > I just noticed that the interrupt function declaration is missing the
> > __isr prefix, it should be
> > __isr void RTC_isr(void)
> >
> > Also both if(ILR&0x01) and if(ILR&0x03) are true every time the
> > interrupt fires (because IRL equals 1) so you should consider using
> > if(ILR&0x02) to check the alarm flag
> >
> >
> im getting more error if a add __isr prefix
>
> _
>
What do you mean by that?
Your original code wasn't giving any errors and adding __isr compiles fine too.
You still haven't specified your compiler , is it keil uvision or not?

When you ask your help you have to provide proper info, you didn't tell us your mcu model, the compiler or the error you get.
First it was the interrupt not executing and now you say more errors , what kind of errors?
--
Alex
---------------------
http://alexan.edaboard.eu/ (Home of ARMwizard, a free tool for peripheral initialization of LPC2xxx/17xx/13xx/11xx/122x microcontrollers )



Alex,

On Fri, 2012-10-05 at 17:37 +0300, Alexan_e wrote:
> What do you mean by that?
> Your original code wasn't giving any errors and adding __isr compiles fine too.
> You still haven't specified your compiler , is it keil uvision or not?
>
> When you ask your help you have to provide proper info, you didn't tell us your mcu model, the compiler or the error you get.
> First it was the interrupt not executing and now you say more errors , what kind of errors?

This student want's us to program his school project,
look at the quote from his email at 16:12 :


sorry i did not get can u reprogram that my program with interrupt
genterating for every 20 min plz do this


I am not going to do that.

Preetham,

If you want help you should provide all the information necessary
to us to be able to help, like processor, compiler and most important
the stuff and information you have already tried and read.
Alex has asked you for that and it should have been the first pieces
of information in your original post.

roelof