EmbeddedRelated.com
Forums
Memfault Beyond the Launch

LPC2378 IRQ issue

Started by "Mau...@yahoo.com.br [lpc2000]" February 1, 2017
Hello guys,
Im working on a new project and am having som problems using interrupts. It is a custom board and I'm using the UART1 RDA interrupt as FIQ, timer1 and EINT3 as vectored IRQ.The sources for EINT3 are the pins P2.5, P2.6 and P2.8, sensing the falling edge.
The system starts fine and work great for a while, then, after some pin state change on one of the EINT3 pins he reaches the "__default_handler" or "Abort_handler" entry on disassembly and stays there until reset.
I've tried working only with UART1 and timer1 interrupts (without EINT3) and the result is the same, but it takes more time to happen.
I can not see what I'm doing wrong, so, can someone give me a light?

I"m using IAR Embedded Workbech IDE.
- My UART1 initialization routine:
void init_serial1(){      PINSEL4 |= 0x0000000A;             //TXD1 and RXD1 (on P2.0 and P2.1)      PCONP   |= (1<<4);                        //power up UART1
      U1FCR    = 0x07;                            //turn on FIFO an reset
      U1FDR    = 0x00;                            //fractional baudrate configuration
      U1LCR    = 0x80;                            //set DLAB
      U1DLL    = 0x75;                             //baud rate low
      U1DLM    = 0x00;                            //baudrate high
      U1LCR    =0x03;                             //configure stop bit, parity and length
      U1IER    = 0x01;                              //interrupt enable
}
- My timer1 init function:
void init_timer1 (){      PCONP |= (1<<2);                          //power up TMR1
      T1TCR = 0;                                      //disable T1
      T1PR = (18000000/1000) - 1;      //Prescaler for 1ms
      T1TCR = 2;                                      //init T1
      T1TCR = 1;                                      //enable T1
}
- interrupt configuration:
__disable_interrupt();
  
   VICINTSELECT = 0x00;                            //clears everything 
   VICINTENCLEAR = 0xFFFFFFFF;
   VICADDRESS = 0x00;
   VICPROTECTION = 0;
  
   //UART1 - FIQ
   VICINTSELECT =  (1 << VIC_UART1);                 //FIQ interrupt
   VICINTENABLE =  (1 << VIC_UART1);                 //enable interrupt
  
   //timer 1 - IRQ
   VICINTSELECT &=  ~(1 << VIC_TIMER1);              //IRQ tipe
   VICVECTADDR5 = (uint32) &irq_timer1;
   VICVECTPRIORITY5 = 15;
   VICINTENABLE |= (1 << VIC_TIMER1);                //enable timer1 interrupt (IRQ)
  
   //EXTINT3 - IRQ
   //falling edge on pins P2.5,  P2.6 e P2.8
   IO2INTENF = 0x160;
   //configures EXTINT3 as edge sensitive
   EXTMODE = (1<<3);
   //clear the interrupt flag
   EXTINT = (1<<3);
   VICINTSELECT &=  ~(1 << VIC_EINT3);                 //IRQ tipe
   VICVECTADDR17 = (uint32) &irq_eint3;
   VICVECTPRIORITY17 = 0;
   VICINTENABLE |= (1 << VIC_EINT3);                     //enable EINT3 interrupt (IRQ)
   __enable_interrupt();
- FIQ handler

__fiq __arm void FIQ_Handler (void)
{
    modbus();                                            //MODBUS slave routine
    VICADDRESS = 0x00;                       //clear interrupt
}

- IRQ handler
__irq __arm void IRQ_Handler(void)
{
    void (*interrupt_function)();
    uint32 vector;

    vector = VICADDRESS;                                 // Get interrupt vector.
    interrupt_function = (void(*)())vector;
    (*interrupt_function)();                                   // Call vectored interrupt function
    VICADDRESS = 0x00;                                    //clear interrupt}

- timer1 irq handler:
void irq_timer1(void)
{        //my software control counters and flags
       timeTick = timeTick + 1.0;
       cont++;
       if (cont>= 3)
       {
           flag0 = 1;
           totalPulses = pulses;
           pulses= 0;
           cont = 0;
       }
       //loads the timer again
       T1IR = 0x3F;                                    //clear interrupt flag
       T1MR0 = T1TC + 1000;                 //loads the new time to counter
       T1MCR |= (1<<0);                          //enable MR0 interrupt
}
- EINT3 irq handler
void irq_eint3(void)
{    //my software control flags and counters
    //test pin P2.5
    if (IO2INTSTATF & (1<<5))
    {
        var1++;
        IO2INTCLR = (1<<5);                        //clear interrupt flag
    }
    //test pin P2.6
    if (IO2INTSTATF & (1<<6))
    {
        flag1 = 1;
        IO2INTCLR = (1<<6);                        //clear interrupt
    }
    //test pin P2.8
    if (IO2INTSTATF & (1<<8))
    {
        flag2 = 1;
        LED_ON;                                                //turn on led
        IO2INTCLR = (1<<8);                           //clear interrupt
    }
    //clear EINT3 interrupt flag
    EXTINT = (1<<3);
}
If someone needs more details I can provide them.
Best Regards,Mauro Lenz

An Engineer's Guide to the LPC2100 Series

It has been a long time that I designed firmwares. But one thing that you
can look is to skip the PLL for clocking and use the default clock source.
If I am correct it was 12MHz As I remember it was difficult to setup the
clock right again with the PLL every time coming out of an interrupt.

On Wed, Feb 1, 2017 at 11:31 AM, Mauro Luiz m...@yahoo.com.br
[lpc2000] wrote:

> Hello guys,
>
> Im working on a new project and am having som problems using interrupts.
> It is a custom board and I'm using the UART1 RDA interrupt as FIQ, timer1
> and EINT3 as vectored IRQ.
> The sources for EINT3 are the pins P2.5, P2.6 and P2.8, sensing the
> falling edge.
>
> The system starts fine and work great for a while, then, after some pin
> state change on one of the EINT3 pins he reaches the "__default_handler" or
> "Abort_handler" entry on disassembly and stays there until reset.
>
> I've tried working only with UART1 and timer1 interrupts (without EINT3)
> and the result is the same, but it takes more time to happen.
>
> I can not see what I'm doing wrong, so, can someone give me a light?
> I"m using IAR Embedded Workbech IDE.
>
> - My UART1 initialization routine:
>
> *void init_serial1()*
> *{*
> * PINSEL4 |= 0x0000000A; //TXD1 and RXD1 (on P2.0 and
> P2.1)*
> * PCONP |= (1<<4); //power up UART1
> U1FCR = 0x07; //turn on FIFO an reset
> U1FDR = 0x00; //fractional baudrate
> configuration U1LCR = 0x80; //set
> DLAB U1DLL = 0x75; //baud rate low
> U1DLM = 0x00; //baudrate high U1LCR
> =0x03; //configure stop bit, parity and
> length U1IER = 0x01; //interrupt
> enable*
> *}*
>
> - My timer1 init function:
>
> *void init_timer1 ()*
> *{*
>
> * PCONP |= (1<<2); //power up TMR1
> T1TCR = 0; //disable T1 T1PR > (18000000/1000) - 1; //Prescaler for 1ms T1TCR > 2; //init T1 T1TCR > 1; //enable T1*
> *}*
>
> - interrupt configuration:
>
> *__disable_interrupt(); VICINTSELECT > 0x00; //clears everything VICINTENCLEAR > 0xFFFFFFFF; VICADDRESS = 0x00; VICPROTECTION = 0; //UART1 - FIQ
> VICINTSELECT = (1 << VIC_UART1); //FIQ interrupt
> VICINTENABLE = (1 << VIC_UART1); //enable interrupt
> //timer 1 - IRQ VICINTSELECT &= ~(1 << VIC_TIMER1); //IRQ
> tipe VICVECTADDR5 = (uint32) &irq_timer1; VICVECTPRIORITY5 = 15;
> VICINTENABLE |= (1 << VIC_TIMER1); //enable timer1 interrupt
> (IRQ) //EXTINT3 - IRQ //falling edge on pins P2.5, P2.6 e P2.8
> IO2INTENF = 0x160; //configures EXTINT3 as edge sensitive EXTMODE > (1<<3); //clear the interrupt flag EXTINT = (1<<3); VICINTSELECT &> ~(1 << VIC_EINT3); //IRQ tipe VICVECTADDR17 = (uint32)
> &irq_eint3; VICVECTPRIORITY17 = 0; VICINTENABLE |= (1 <<
> VIC_EINT3); //enable EINT3 interrupt (IRQ)
> __enable_interrupt();*
> - FIQ handler
> *__fiq __arm void FIQ_Handler (void){
> modbus(); //MODBUS slave
> routine VICADDRESS = 0x00; //clear interrupt}*
>
> - IRQ handler
>
> *__irq __arm void IRQ_Handler(void){ void (*interrupt_function)();
> uint32 vector; vector = VICADDRESS; //
> Get interrupt vector. interrupt_function = (void(*)())vector;
> (*interrupt_function)(); // Call vectored
> interrupt function VICADDRESS = 0x00;
> //clear interrupt*
> *}*
>
> - timer1 irq handler:
> *void irq_timer1(void){*
>
> * //my software control counters and flags*
> * timeTick = *
>
> *timeTick + 1.0; cont++; if (cont>= 3) {
> flag0 = 1; totalPulses = pulses; *
> *pulses= 0; cont = 0; } //loads the timer
> again T1IR = 0x3F; //clear
> interrupt flag T1MR0 = T1TC + 1000; //loads the new
> time to counter T1MCR |= (1<<0); //enable
> MR0 interrupt}*
> - EINT3 irq handler
> *void irq_eint3(void){*
>
> * //my software control flags and counters*
>
> * //test pin P2.5 if (IO2INTSTATF & (1<<5)) {
> var1++; IO2INTCLR = (1<<5); //clear interrupt
> flag } //test pin P2.6 if (IO2INTSTATF & (1<<6)) { flag1
> = 1; IO2INTCLR = (1<<6); //clear interrupt
> } //test pin P2.8 if (IO2INTSTATF & (1<<8)) { flag2 > 1; LED_ON; //turn on
> led IO2INTCLR = (1<<8); //clear
> interrupt } //clear EINT3 interrupt flag EXTINT = (1<<3);}*
> If someone needs more details I can provide them.
>
> Best Regards,
> Mauro Lenz
>

--
Shashank Maheshwari
Try using IRQ only and disable FIQ. Problem solved.

I didn't check your code but I remember having the same problem when using
FIQ and IRQ.

Problem is when FIQ interrupts an IRQ, registers are not saved and when FIQ
returns PC goes to IRQ return address and it messes up execution, or maybe
it is the other way around. You'll need assembly saving registers on FIQ
enter if you use it (or is it on IRQ enter?, not sure now, read about it on
the internet).

Or probably I've got it all messed up, it was too many years ago.

By the way I think I didn't see anyone posting a question here for years.

Cumprimentos,

Bernardo Marques

Em 01/02/2017 16:37, "Mauro Luiz m...@yahoo.com.br [lpc2000]" <
l...> escreveu:

> Hello guys,
>
> Im working on a new project and am having som problems using interrupts.
> It is a custom board and I'm using the UART1 RDA interrupt as FIQ, timer1
> and EINT3 as vectored IRQ.
> The sources for EINT3 are the pins P2.5, P2.6 and P2.8, sensing the
> falling edge.
>
> The system starts fine and work great for a while, then, after some pin
> state change on one of the EINT3 pins he reaches the "__default_handler" or
> "Abort_handler" entry on disassembly and stays there until reset.
>
> I've tried working only with UART1 and timer1 interrupts (without EINT3)
> and the result is the same, but it takes more time to happen.
>
> I can not see what I'm doing wrong, so, can someone give me a light?
> I"m using IAR Embedded Workbech IDE.
>
> - My UART1 initialization routine:
>
> *void init_serial1()*
> *{*
> * PINSEL4 |= 0x0000000A; //TXD1 and RXD1 (on P2.0 and
> P2.1)*
> * PCONP |= (1<<4); //power up UART1
> U1FCR = 0x07; //turn on FIFO an reset
> U1FDR = 0x00; //fractional baudrate
> configuration U1LCR = 0x80; //set
> DLAB U1DLL = 0x75; //baud rate low
> U1DLM = 0x00; //baudrate high U1LCR
> =0x03; //configure stop bit, parity and
> length U1IER = 0x01; //interrupt
> enable*
> *}*
>
> - My timer1 init function:
>
> *void init_timer1 ()*
> *{*
>
> * PCONP |= (1<<2); //power up TMR1
> T1TCR = 0; //disable T1 T1PR > (18000000/1000) - 1; //Prescaler for 1ms T1TCR > 2; //init T1 T1TCR > 1; //enable T1*
> *}*
>
> - interrupt configuration:
>
> *__disable_interrupt(); VICINTSELECT > 0x00; //clears everything VICINTENCLEAR > 0xFFFFFFFF; VICADDRESS = 0x00; VICPROTECTION = 0; //UART1 - FIQ
> VICINTSELECT = (1 << VIC_UART1); //FIQ interrupt
> VICINTENABLE = (1 << VIC_UART1); //enable interrupt
> //timer 1 - IRQ VICINTSELECT &= ~(1 << VIC_TIMER1); //IRQ
> tipe VICVECTADDR5 = (uint32) &irq_timer1; VICVECTPRIORITY5 = 15;
> VICINTENABLE |= (1 << VIC_TIMER1); //enable timer1 interrupt
> (IRQ) //EXTINT3 - IRQ //falling edge on pins P2.5, P2.6 e P2.8
> IO2INTENF = 0x160; //configures EXTINT3 as edge sensitive EXTMODE > (1<<3); //clear the interrupt flag EXTINT = (1<<3); VICINTSELECT &> ~(1 << VIC_EINT3); //IRQ tipe VICVECTADDR17 = (uint32)
> &irq_eint3; VICVECTPRIORITY17 = 0; VICINTENABLE |= (1 <<
> VIC_EINT3); //enable EINT3 interrupt (IRQ)
> __enable_interrupt();*
> - FIQ handler
> *__fiq __arm void FIQ_Handler (void){
> modbus(); //MODBUS slave
> routine VICADDRESS = 0x00; //clear interrupt}*
>
> - IRQ handler
>
> *__irq __arm void IRQ_Handler(void){ void (*interrupt_function)();
> uint32 vector; vector = VICADDRESS; //
> Get interrupt vector. interrupt_function = (void(*)())vector;
> (*interrupt_function)(); // Call vectored
> interrupt function VICADDRESS = 0x00;
> //clear interrupt*
> *}*
>
> - timer1 irq handler:
> *void irq_timer1(void){*
>
> * //my software control counters and flags*
> * timeTick = *
>
> *timeTick + 1.0; cont++; if (cont>= 3) {
> flag0 = 1; totalPulses = pulses; *
> *pulses= 0; cont = 0; } //loads the timer
> again T1IR = 0x3F; //clear
> interrupt flag T1MR0 = T1TC + 1000; //loads the new
> time to counter T1MCR |= (1<<0); //enable
> MR0 interrupt}*
> - EINT3 irq handler
> *void irq_eint3(void){*
>
> * //my software control flags and counters*
>
> * //test pin P2.5 if (IO2INTSTATF & (1<<5)) {
> var1++; IO2INTCLR = (1<<5); //clear interrupt
> flag } //test pin P2.6 if (IO2INTSTATF & (1<<6)) { flag1
> = 1; IO2INTCLR = (1<<6); //clear interrupt
> } //test pin P2.8 if (IO2INTSTATF & (1<<8)) { flag2 > 1; LED_ON; //turn on
> led IO2INTCLR = (1<<8); //clear
> interrupt } //clear EINT3 interrupt flag EXTINT = (1<<3);}*
> If someone needs more details I can provide them.
>
> Best Regards,
> Mauro Lenz
>
What?
Never had such experience. There is no need to change PLL when entering or
exiting interrupts. PLL is enabled on startup and interrupts do not
influence. Power Saving modes might but that is not what is asked.

Regards,

Bernardo Marques

Em 01/02/2017 17:53, "Shashank Maheshwari s...@gmail.com [lpc2000]" <
l...> escreveu:

It has been a long time that I designed firmwares. But one thing that you
can look is to skip the PLL for clocking and use the default clock source.
If I am correct it was 12MHz As I remember it was difficult to setup the
clock right again with the PLL every time coming out of an interrupt.

On Wed, Feb 1, 2017 at 11:31 AM, Mauro Luiz m...@yahoo.com.br
[lpc2000] wrote:

> Hello guys,
>
> Im working on a new project and am having som problems using interrupts.
> It is a custom board and I'm using the UART1 RDA interrupt as FIQ, timer1
> and EINT3 as vectored IRQ.
> The sources for EINT3 are the pins P2.5, P2.6 and P2.8, sensing the
> falling edge.
>
> The system starts fine and work great for a while, then, after some pin
> state change on one of the EINT3 pins he reaches the "__default_handler" or
> "Abort_handler" entry on disassembly and stays there until reset.
>
> I've tried working only with UART1 and timer1 interrupts (without EINT3)
> and the result is the same, but it takes more time to happen.
>
> I can not see what I'm doing wrong, so, can someone give me a light?
> I"m using IAR Embedded Workbech IDE.
>
> - My UART1 initialization routine:
>
> *void init_serial1()*
> *{*
> * PINSEL4 |= 0x0000000A; //TXD1 and RXD1 (on P2.0 and
> P2.1)*
> * PCONP |= (1<<4); //power up UART1
> U1FCR = 0x07; //turn on FIFO an reset
> U1FDR = 0x00; //fractional baudrate
> configuration U1LCR = 0x80; //set
> DLAB U1DLL = 0x75; //baud rate low
> U1DLM = 0x00; //baudrate high U1LCR
> =0x03; //configure stop bit, parity and
> length U1IER = 0x01; //interrupt
> enable*
> *}*
>
> - My timer1 init function:
>
> *void init_timer1 ()*
> *{*
>
> * PCONP |= (1<<2); //power up TMR1
> T1TCR = 0; //disable T1 T1PR > (18000000/1000) - 1; //Prescaler for 1ms T1TCR > 2; //init T1 T1TCR > 1; //enable T1*
> *}*
>
> - interrupt configuration:
>
> *__disable_interrupt(); VICINTSELECT > 0x00; //clears everything VICINTENCLEAR > 0xFFFFFFFF; VICADDRESS = 0x00; VICPROTECTION = 0; //UART1 - FIQ
> VICINTSELECT = (1 << VIC_UART1); //FIQ interrupt
> VICINTENABLE = (1 << VIC_UART1); //enable interrupt
> //timer 1 - IRQ VICINTSELECT &= ~(1 << VIC_TIMER1); //IRQ
> tipe VICVECTADDR5 = (uint32) &irq_timer1; VICVECTPRIORITY5 = 15;
> VICINTENABLE |= (1 << VIC_TIMER1); //enable timer1 interrupt
> (IRQ) //EXTINT3 - IRQ //falling edge on pins P2.5, P2.6 e P2.8
> IO2INTENF = 0x160; //configures EXTINT3 as edge sensitive EXTMODE > (1<<3); //clear the interrupt flag EXTINT = (1<<3); VICINTSELECT &> ~(1 << VIC_EINT3); //IRQ tipe VICVECTADDR17 = (uint32)
> &irq_eint3; VICVECTPRIORITY17 = 0; VICINTENABLE |= (1 <<
> VIC_EINT3); //enable EINT3 interrupt (IRQ)
> __enable_interrupt();*
> - FIQ handler
> *__fiq __arm void FIQ_Handler (void){
> modbus(); //MODBUS slave
> routine VICADDRESS = 0x00; //clear interrupt}*
>
> - IRQ handler
>
> *__irq __arm void IRQ_Handler(void){ void (*interrupt_function)();
> uint32 vector; vector = VICADDRESS; //
> Get interrupt vector. interrupt_function = (void(*)())vector;
> (*interrupt_function)(); // Call vectored
> interrupt function VICADDRESS = 0x00;
> //clear interrupt*
> *}*
>
> - timer1 irq handler:
> *void irq_timer1(void){*
>
> * //my software control counters and flags*
> * timeTick = *
>
> *timeTick + 1.0; cont++; if (cont>= 3) {
> flag0 = 1; totalPulses = pulses; *
> *pulses= 0; cont = 0; } //loads the timer
> again T1IR = 0x3F; //clear
> interrupt flag T1MR0 = T1TC + 1000; //loads the new
> time to counter T1MCR |= (1<<0); //enable
> MR0 interrupt}*
> - EINT3 irq handler
> *void irq_eint3(void){*
>
> * //my software control flags and counters*
>
> * //test pin P2.5 if (IO2INTSTATF & (1<<5)) {
> var1++; IO2INTCLR = (1<<5); //clear interrupt
> flag } //test pin P2.6 if (IO2INTSTATF & (1<<6)) { flag1
> = 1; IO2INTCLR = (1<<6); //clear interrupt
> } //test pin P2.8 if (IO2INTSTATF & (1<<8)) { flag2 > 1; LED_ON; //turn on
> led IO2INTCLR = (1<<8); //clear
> interrupt } //clear EINT3 interrupt flag EXTINT = (1<<3);}*
> If someone needs more details I can provide them.
>
> Best Regards,
> Mauro Lenz
--
Shashank Maheshwari
Hello guys,
I agree with Bernardo, I didn't think that PLL has to do with interrupts, but, by the way, I test it too. I test all your options (only irq, without PLL) and in all cases happens the same, it works for a while and reaches the undefined handler. At last, I test it with an other cstartup.s file I take from a example. When I only request the online data from system it works fine but it reaches the undefined handler when I try to download the data from SD card. Now I'm distrusting the problem I'm facing is related to the SD card library (I'm using EFSL library). I haven't test the system without it because the SD card is essential to my system, but on other applications (without SD card) I have the interrupt working (at least one FIQ interrupt) and on this system not even one FIQ interrupt works fine.Someone using the EFSL library faced the some similar problem?
Best Regards,Mauro Lenz

On Wednesday, February 1, 2017 7:05 PM, "Bernardo Marques b...@gmail.com [lpc2000]" wrote:

  What?Never had such experience. There is no need to change PLL when entering or exiting interrupts. PLL is enabled on startup and interrupts do not influence. Power Saving modes might but that is not what is asked.

Regards,

Bernardo Marques
Em 01/02/2017 17:53, "Shashank Maheshwari s...@gmail.com [lpc2000]" escreveu:

  It has been a long time that I designed firmwares. But one thing that you can look is to skip the PLL for clocking and use the default clock source. If I am correct it was 12MHz As I remember it was difficult to setup the clock right again with the PLL every time coming out of an interrupt.
On Wed, Feb 1, 2017 at 11:31 AM, Mauro Luiz m...@yahoo.com.br [lpc2000] wrote:

  Hello guys,
Im working on a new project and am having som problems using interrupts. It is a custom board and I'm using the UART1 RDA interrupt as FIQ, timer1 and EINT3 as vectored IRQ.The sources for EINT3 are the pins P2.5, P2.6 and P2.8, sensing the falling edge.
The system starts fine and work great for a while, then, after some pin state change on one of the EINT3 pins he reaches the "__default_handler" or "Abort_handler" entry on disassembly and stays there until reset.
I've tried working only with UART1 and timer1 interrupts (without EINT3) and the result is the same, but it takes more time to happen.
I can not see what I'm doing wrong, so, can someone give me a light?

I"m using IAR Embedded Workbech IDE.
- My UART1 initialization routine:
void init_serial1(){      PINSEL4 |= 0x0000000A;             //TXD1 and RXD1 (on P2.0 and P2.1)      PCONP   |= (1<<4);                        //power up UART1
      U1FCR    = 0x07;                             //turn on FIFO an reset
      U1FDR    = 0x00;                            //fractional baudrate configuration
      U1LCR    = 0x80;                            //set DLAB
      U1DLL    = 0x75;                             //baud rate low
      U1DLM    = 0x00;                             //baudrate high
      U1LCR    =0x03;                              //configure stop bit, parity and length
      U1IER    = 0x01;                               //interrupt enable
}
- My timer1 init function:
void init_timer1 (){      PCONP |= (1<<2);                           //power up TMR1
      T1TCR = 0;                                       //disable T1
      T1PR = (18000000/1000) - 1;      //Prescaler for 1ms
      T1TCR = 2;                                       //init T1
      T1TCR = 1;                                      //enable T1
}
- interrupt configuration:
__disable_interrupt();
  
   VICINTSELECT = 0x00;                             //clears everything 
   VICINTENCLEAR = 0xFFFFFFFF;
   VICADDRESS = 0x00;
   VICPROTECTION = 0;
  
   //UART1 - FIQ
   VICINTSELECT =  (1 << VIC_UART1);                 //FIQ interrupt
   VICINTENABLE =  (1 << VIC_UART1);                 //enable interrupt
  
   //timer 1 - IRQ
   VICINTSELECT &=  ~(1 << VIC_TIMER1);              //IRQ tipe
   VICVECTADDR5 = (uint32) &irq_timer1;
   VICVECTPRIORITY5 = 15;
   VICINTENABLE |= (1 << VIC_TIMER1);                //enable timer1 interrupt (IRQ)
  
   //EXTINT3 - IRQ
   //falling edge on pins P2.5,  P2.6 e P2.8
   IO2INTENF = 0x160;
   //configures EXTINT3 as edge sensitive
   EXTMODE = (1<<3);
   //clear the interrupt flag
   EXTINT = (1<<3);
   VICINTSELECT &=  ~(1 << VIC_EINT3);                 //IRQ tipe
   VICVECTADDR17 = (uint32) &irq_eint3;
   VICVECTPRIORITY17 = 0;
   VICINTENABLE |= (1 << VIC_EINT3);                      //enable EINT3 interrupt (IRQ)
   __enable_interrupt();
- FIQ handler

__fiq __arm void FIQ_Handler (void)
{
    modbus();                                             //MODBUS slave routine
    VICADDRESS = 0x00;                       //clear interrupt
}

- IRQ handler
__irq __arm void IRQ_Handler(void)
{
    void (*interrupt_function)();
    uint32 vector;

    vector = VICADDRESS;                                  // Get interrupt vector.
    interrupt_function = (void(*)())vector;
    (*interrupt_function)();                                    // Call vectored interrupt function
    VICADDRESS = 0x00;                                     //clear interrupt}

- timer1 irq handler:
void irq_timer1(void)
{        //my software control counters and flags
       timeTick = timeTick + 1.0;
       cont++;
       if (cont>= 3)
       {
           flag0 = 1;
           totalPulses = pulses;
           pulses= 0;
           cont = 0;
       }
       //loads the timer again
       T1IR = 0x3F;                                     //clear interrupt flag
       T1MR0 = T1TC + 1000;                 //loads the new time to counter
       T1MCR |= (1<<0);                          //enable MR0 interrupt
}
- EINT3 irq handler
void irq_eint3(void)
{    //my software control flags and counters
    //test pin P2.5
    if (IO2INTSTATF & (1<<5))
    {
        var1++;
        IO2INTCLR = (1<<5);                        //clear interrupt flag
    }
    //test pin P2.6
    if (IO2INTSTATF & (1<<6))
    {
        flag1 = 1;
        IO2INTCLR = (1<<6);                        //clear interrupt
    }
    //test pin P2.8
    if (IO2INTSTATF & (1<<8))
    {
        flag2 = 1;
        LED_ON;                                                 //turn on led
        IO2INTCLR = (1<<8);                            //clear interrupt
    }
    //clear EINT3 interrupt flag
    EXTINT = (1<<3);
}
If someone needs more details I can provide them.
Best Regards,Mauro Lenz

--
Shashank Maheshwari

#yiv6026656567 #yiv6026656567 -- #yiv6026656567ygrp-mkp {border:1px solid #d8d8d8;font-family:Arial;margin:10px 0;padding:0 10px;}#yiv6026656567 #yiv6026656567ygrp-mkp hr {border:1px solid #d8d8d8;}#yiv6026656567 #yiv6026656567ygrp-mkp #yiv6026656567hd {color:#628c2a;font-size:85%;font-weight:700;line-height:122%;margin:10px 0;}#yiv6026656567 #yiv6026656567ygrp-mkp #yiv6026656567ads {margin-bottom:10px;}#yiv6026656567 #yiv6026656567ygrp-mkp .yiv6026656567ad {padding:0 0;}#yiv6026656567 #yiv6026656567ygrp-mkp .yiv6026656567ad p {margin:0;}#yiv6026656567 #yiv6026656567ygrp-mkp .yiv6026656567ad a {color:#0000ff;text-decoration:none;}#yiv6026656567 #yiv6026656567ygrp-sponsor #yiv6026656567ygrp-lc {font-family:Arial;}#yiv6026656567 #yiv6026656567ygrp-sponsor #yiv6026656567ygrp-lc #yiv6026656567hd {margin:10px 0px;font-weight:700;font-size:78%;line-height:122%;}#yiv6026656567 #yiv6026656567ygrp-sponsor #yiv6026656567ygrp-lc .yiv6026656567ad {margin-bottom:10px;padding:0 0;}#yiv6026656567 #yiv6026656567actions {font-family:Verdana;font-size:11px;padding:10px 0;}#yiv6026656567 #yiv6026656567activity {background-color:#e0ecee;float:left;font-family:Verdana;font-size:10px;padding:10px;}#yiv6026656567 #yiv6026656567activity span {font-weight:700;}#yiv6026656567 #yiv6026656567activity span:first-child {text-transform:uppercase;}#yiv6026656567 #yiv6026656567activity span a {color:#5085b6;text-decoration:none;}#yiv6026656567 #yiv6026656567activity span span {color:#ff7900;}#yiv6026656567 #yiv6026656567activity span .yiv6026656567underline {text-decoration:underline;}#yiv6026656567 .yiv6026656567attach {clear:both;display:table;font-family:Arial;font-size:12px;padding:10px 0;width:400px;}#yiv6026656567 .yiv6026656567attach div a {text-decoration:none;}#yiv6026656567 .yiv6026656567attach img {border:none;padding-right:5px;}#yiv6026656567 .yiv6026656567attach label {display:block;margin-bottom:5px;}#yiv6026656567 .yiv6026656567attach label a {text-decoration:none;}#yiv6026656567 blockquote {margin:0 0 0 4px;}#yiv6026656567 .yiv6026656567bold {font-family:Arial;font-size:13px;font-weight:700;}#yiv6026656567 .yiv6026656567bold a {text-decoration:none;}#yiv6026656567 dd.yiv6026656567last p a {font-family:Verdana;font-weight:700;}#yiv6026656567 dd.yiv6026656567last p span {margin-right:10px;font-family:Verdana;font-weight:700;}#yiv6026656567 dd.yiv6026656567last p span.yiv6026656567yshortcuts {margin-right:0;}#yiv6026656567 div.yiv6026656567attach-table div div a {text-decoration:none;}#yiv6026656567 div.yiv6026656567attach-table {width:400px;}#yiv6026656567 div.yiv6026656567file-title a, #yiv6026656567 div.yiv6026656567file-title a:active, #yiv6026656567 div.yiv6026656567file-title a:hover, #yiv6026656567 div.yiv6026656567file-title a:visited {text-decoration:none;}#yiv6026656567 div.yiv6026656567photo-title a, #yiv6026656567 div.yiv6026656567photo-title a:active, #yiv6026656567 div.yiv6026656567photo-title a:hover, #yiv6026656567 div.yiv6026656567photo-title a:visited {text-decoration:none;}#yiv6026656567 div#yiv6026656567ygrp-mlmsg #yiv6026656567ygrp-msg p a span.yiv6026656567yshortcuts {font-family:Verdana;font-size:10px;font-weight:normal;}#yiv6026656567 .yiv6026656567green {color:#628c2a;}#yiv6026656567 .yiv6026656567MsoNormal {margin:0 0 0 0;}#yiv6026656567 o {font-size:0;}#yiv6026656567 #yiv6026656567photos div {float:left;width:72px;}#yiv6026656567 #yiv6026656567photos div div {border:1px solid #666666;height:62px;overflow:hidden;width:62px;}#yiv6026656567 #yiv6026656567photos div label {color:#666666;font-size:10px;overflow:hidden;text-align:center;white-space:nowrap;width:64px;}#yiv6026656567 #yiv6026656567reco-category {font-size:77%;}#yiv6026656567 #yiv6026656567reco-desc {font-size:77%;}#yiv6026656567 .yiv6026656567replbq {margin:4px;}#yiv6026656567 #yiv6026656567ygrp-actbar div a:first-child {margin-right:2px;padding-right:5px;}#yiv6026656567 #yiv6026656567ygrp-mlmsg {font-size:13px;font-family:Arial, helvetica, clean, sans-serif;}#yiv6026656567 #yiv6026656567ygrp-mlmsg table {font-size:inherit;font:100%;}#yiv6026656567 #yiv6026656567ygrp-mlmsg select, #yiv6026656567 input, #yiv6026656567 textarea {font:99% Arial, Helvetica, clean, sans-serif;}#yiv6026656567 #yiv6026656567ygrp-mlmsg pre, #yiv6026656567 code {font:115% monospace;}#yiv6026656567 #yiv6026656567ygrp-mlmsg * {line-height:1.22em;}#yiv6026656567 #yiv6026656567ygrp-mlmsg #yiv6026656567logo {padding-bottom:10px;}#yiv6026656567 #yiv6026656567ygrp-msg p a {font-family:Verdana;}#yiv6026656567 #yiv6026656567ygrp-msg p#yiv6026656567attach-count span {color:#1E66AE;font-weight:700;}#yiv6026656567 #yiv6026656567ygrp-reco #yiv6026656567reco-head {color:#ff7900;font-weight:700;}#yiv6026656567 #yiv6026656567ygrp-reco {margin-bottom:20px;padding:0px;}#yiv6026656567 #yiv6026656567ygrp-sponsor #yiv6026656567ov li a {font-size:130%;text-decoration:none;}#yiv6026656567 #yiv6026656567ygrp-sponsor #yiv6026656567ov li {font-size:77%;list-style-type:square;padding:6px 0;}#yiv6026656567 #yiv6026656567ygrp-sponsor #yiv6026656567ov ul {margin:0;padding:0 0 0 8px;}#yiv6026656567 #yiv6026656567ygrp-text {font-family:Georgia;}#yiv6026656567 #yiv6026656567ygrp-text p {margin:0 0 1em 0;}#yiv6026656567 #yiv6026656567ygrp-text tt {font-size:120%;}#yiv6026656567 #yiv6026656567ygrp-vital ul li:last-child {border-right:none !important;}#yiv6026656567
Makes sense. If I remember better now it was power down modes that caused
the issue. Interrupt was used to get out of power down modes and made it
difficult to setup proper clock. So primarily power down modes issue rather
than interrupt. Try the other alternatives shared on this thread by others!
atb

On Wed, Feb 1, 2017 at 4:05 PM, Bernardo Marques b...@gmail.com
[lpc2000] wrote:

> What?
> Never had such experience. There is no need to change PLL when entering or
> exiting interrupts. PLL is enabled on startup and interrupts do not
> influence. Power Saving modes might but that is not what is asked.
>
> Regards,
>
> Bernardo Marques
>
> Em 01/02/2017 17:53, "Shashank Maheshwari s...@gmail.com
> [lpc2000]" escreveu:
>
> It has been a long time that I designed firmwares. But one thing that you
> can look is to skip the PLL for clocking and use the default clock source.
> If I am correct it was 12MHz As I remember it was difficult to setup the
> clock right again with the PLL every time coming out of an interrupt.
>
> On Wed, Feb 1, 2017 at 11:31 AM, Mauro Luiz m...@yahoo.com.br
> [lpc2000] wrote:
>
>> Hello guys,
>>
>> Im working on a new project and am having som problems using interrupts.
>> It is a custom board and I'm using the UART1 RDA interrupt as FIQ, timer1
>> and EINT3 as vectored IRQ.
>> The sources for EINT3 are the pins P2.5, P2.6 and P2.8, sensing the
>> falling edge.
>>
>> The system starts fine and work great for a while, then, after some pin
>> state change on one of the EINT3 pins he reaches the "__default_handler" or
>> "Abort_handler" entry on disassembly and stays there until reset.
>>
>> I've tried working only with UART1 and timer1 interrupts (without EINT3)
>> and the result is the same, but it takes more time to happen.
>>
>> I can not see what I'm doing wrong, so, can someone give me a light?
>> I"m using IAR Embedded Workbech IDE.
>>
>> - My UART1 initialization routine:
>>
>> *void init_serial1()*
>> *{*
>> * PINSEL4 |= 0x0000000A; //TXD1 and RXD1 (on P2.0 and
>> P2.1)*
>> * PCONP |= (1<<4); //power up UART1
>> U1FCR = 0x07; //turn on FIFO an reset
>> U1FDR = 0x00; //fractional baudrate
>> configuration U1LCR = 0x80; //set
>> DLAB U1DLL = 0x75; //baud rate low
>> U1DLM = 0x00; //baudrate high U1LCR
>> =0x03; //configure stop bit, parity and
>> length U1IER = 0x01; //interrupt
>> enable*
>> *}*
>>
>> - My timer1 init function:
>>
>> *void init_timer1 ()*
>> *{*
>>
>> * PCONP |= (1<<2); //power up TMR1
>> T1TCR = 0; //disable T1 T1PR >> (18000000/1000) - 1; //Prescaler for 1ms T1TCR >> 2; //init T1 T1TCR >> 1; //enable T1*
>> *}*
>>
>> - interrupt configuration:
>>
>> *__disable_interrupt(); VICINTSELECT >> 0x00; //clears everything VICINTENCLEAR >> 0xFFFFFFFF; VICADDRESS = 0x00; VICPROTECTION = 0; //UART1 - FIQ
>> VICINTSELECT = (1 << VIC_UART1); //FIQ interrupt
>> VICINTENABLE = (1 << VIC_UART1); //enable interrupt
>> //timer 1 - IRQ VICINTSELECT &= ~(1 << VIC_TIMER1); //IRQ
>> tipe VICVECTADDR5 = (uint32) &irq_timer1; VICVECTPRIORITY5 = 15;
>> VICINTENABLE |= (1 << VIC_TIMER1); //enable timer1 interrupt
>> (IRQ) //EXTINT3 - IRQ //falling edge on pins P2.5, P2.6 e P2.8
>> IO2INTENF = 0x160; //configures EXTINT3 as edge sensitive EXTMODE >> (1<<3); //clear the interrupt flag EXTINT = (1<<3); VICINTSELECT &>> ~(1 << VIC_EINT3); //IRQ tipe VICVECTADDR17 = (uint32)
>> &irq_eint3; VICVECTPRIORITY17 = 0; VICINTENABLE |= (1 <<
>> VIC_EINT3); //enable EINT3 interrupt (IRQ)
>> __enable_interrupt();*
>> - FIQ handler
>> *__fiq __arm void FIQ_Handler (void){
>> modbus(); //MODBUS slave
>> routine VICADDRESS = 0x00; //clear interrupt}*
>>
>> - IRQ handler
>>
>> *__irq __arm void IRQ_Handler(void){ void (*interrupt_function)();
>> uint32 vector; vector = VICADDRESS; //
>> Get interrupt vector. interrupt_function = (void(*)())vector;
>> (*interrupt_function)(); // Call vectored
>> interrupt function VICADDRESS = 0x00;
>> //clear interrupt*
>> *}*
>>
>> - timer1 irq handler:
>> *void irq_timer1(void){*
>>
>> * //my software control counters and flags*
>> * timeTick = *
>>
>> *timeTick + 1.0; cont++; if (cont>= 3) {
>> flag0 = 1; totalPulses = pulses; *
>> *pulses= 0; cont = 0; } //loads the timer
>> again T1IR = 0x3F; //clear
>> interrupt flag T1MR0 = T1TC + 1000; //loads the new
>> time to counter T1MCR |= (1<<0); //enable
>> MR0 interrupt}*
>> - EINT3 irq handler
>> *void irq_eint3(void){*
>>
>> * //my software control flags and counters*
>>
>> * //test pin P2.5 if (IO2INTSTATF & (1<<5)) {
>> var1++; IO2INTCLR = (1<<5); //clear interrupt
>> flag } //test pin P2.6 if (IO2INTSTATF & (1<<6)) { flag1
>> = 1; IO2INTCLR = (1<<6); //clear interrupt
>> } //test pin P2.8 if (IO2INTSTATF & (1<<8)) { flag2 >> 1; LED_ON; //turn on
>> led IO2INTCLR = (1<<8); //clear
>> interrupt } //clear EINT3 interrupt flag EXTINT = (1<<3);}*
>> If someone needs more details I can provide them.
>>
>> Best Regards,
>> Mauro Lenz
> --
> Shashank Maheshwari

--
Shashank Maheshwari

Memfault Beyond the Launch