AnsweredAssumed Answered

ISR code not working

Question asked by vinod Karuvat on Jan 12, 2015
Latest reply on Feb 9, 2015 by vinod Karuvat

Hello Friends,

 

I have an unusual problem

I have designed 3 boards (variants of he same app) using the KL04 chip. Now the code used is this -

#include "derivative.h" /* include peripheral declarations */

 

 

 

//void UART0_IRQHandler(void);

 

 

 

// extern void LPTimer_IRQ(void);

// void LPTimer_IRQ(void);

 

 

 

int main(void)

 

{

    int count;

    uint16_t countTemp = 0;

   // asm(" CPSIE i");

   

   

    MCG_C1 |= 0x02;

    SIM_SOPT1 = 0;      

    SIM_SCGC5 |= (SIM_SCGC5_LPTMR_MASK | SIM_SCGC5_PORTB_MASK);//PORTC_PCR1 |= PORT_PCR_MUX(1);//select RTC_CLKIN function

    PORTB_PCR3 |= 0x00000100;    // alternative pin mux selection //

    GPIOB_PDDR |= 0x00000008;    // pin direction //

   

    PORTB_PCR4 |= 0x00000100;    // alternative pin mux selection //

    GPIOB_PDDR |= 0x00000010;    // pin direction //   

       

       

     NVIC_ICPR = 1 << (28);

     NVIC_ISER = 1 << (28);

   

   

     SIM_SCGC5|=SIM_SCGC5_LPTMR_MASK;

     /* Reset LPTMR settings */

     SIM_SOPT1 = 0;   

     SIM_SCGC5 |= (SIM_SCGC5_LPTMR_MASK | SIM_SCGC5_PORTB_MASK);//PORTC_PCR1 |= PORT_PCR_MUX(1);//select RTC_CLKIN function

     LPTMR0_CSR=0;  

     LPTMR0_CSR |= 0x00000040;

     LPTMR0_CMR = 600;

    

    

     GPIOB_PTOR |= (1 << 3);

     GPIOB_PTOR |= (1 << 4);  

   

   

     GPIOB_PTOR |= (1 << 3);

     GPIOB_PTOR |= (1 << 4);  

      /* Start the timer */ 

     LPTMR0_CSR |= LPTMR_CSR_TEN_MASK;

      /* Wait for counter to reach compare value */

   

     asm("nop");

     

    

      while(1){

          asm("nop");

          asm("nop");

          asm("nop");

          asm("nop");

//         if((LPTMR0_CSR & 0x00000080) == 0x00000080){

//             LPTMR0_CSR &= ~LPTMR_CSR_TEN_MASK;

//             LPTMR0_CSR |= 0x00000080;

//             LPTMR0_CSR |= LPTMR_CSR_TEN_MASK;

//             GPIOB_PTOR |= (1 << 3);

//             GPIOB_PTOR |= (1 << 4);  

//         }

         

      }      

 

}

 

 

void LPTimer_IRQHandler(void){

     asm("nop");

     asm("nop");

     asm("nop");

     asm("nop");

    if((LPTMR0_CSR & 0x00000080) == 0x00000080){

            LPTMR0_CSR &= ~LPTMR_CSR_TEN_MASK;

            LPTMR0_CSR |= 0x00000080;

            LPTMR0_CSR |= LPTMR_CSR_TEN_MASK;

            GPIOB_PTOR |= (1 << 3);

            GPIOB_PTOR |= (1 << 4);  

        }

    

}

 

 

 

Ideally the controller should be interrupted and the control should go to the ISR (void LPTimer_IRQHandler(void)). What I see here is that in the 1st and the 2nd version of the board the ISR works well. But in the 3rd it doesnt. So, to test the 3rd board I made a pin toggle which is executed fine making me feel that this is a purely software issue.

 

I am a bit confused as to how this is being done.

I am stating the part number in all the 3 boards -

 

1) -  M04R4V

       4EYIDK

 

2) M04R5V

    4EYIDM

 

3) M04R5V

    ASAUK

 

Can anyone help me pls

Outcomes