This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Not Getting into the ISR

Hi,

<bI am exploring the MCB2300 board with simulator. I am trying to generate a some signal at MAT0.0.

It is working fine, except that not entering into the ISR.

WHile observing the simulation, when MR0=TCR, interrupt generated,

VICVectAddr took the address of VICVectAddr4. But then it is not taking the address 0, which is last line of ISR.>

Here is the code.

#include <stdio.h>
#include <LPC23xx.H> /* LPC23xx definitions */
#include "LCD.h" /* Graphic LCD function prototypes *

extern __irq void T0_IRQHandler (void);

int main (void) {

int i=0;

PCLKSEL0 |=0x00000000; // pclk=cclk/4=18MHz PINSEL3 |=0x03000000; // Select MAT0.0 Pin 44 P1.28 T0PR=5000; T0MR0=1800-1; // To generate a 1 sec pulse with 18 Mhz Pclk clock T0MCR=3; // Interrupt generated & reset TC on match T0EMR=0x30; // T0TCR=1; //ENABLE Timer VICVectAddr4 = (unsigned long)T0_IRQHandler;/* Set Interrupt Vector Gives ISR Address to VICVectAddr4 */ VICVectCntl4 = 15; /* use it for Timer0 Interrupt */ VICIntEnable = (1 << 4); /* Enable Timer0 Interrupt It gives the content of VICVectAddre4 to VICVectAddr */
}

Here is the ISR

#include <LPC23xx.H> /* LPC23xx definitions */

__irq void T0_IRQHandler (void) {

T0IR|=0x01; // clear interrupt register VICVectAddr=0;//acknowledge interrupt

}

According to the last line of ISR, VectAddre should become 0, which is not happening; while observing the simulator.

Even I tried with disabling the T0TCR=0 as the 1st line of ISR to disable the timer. But TC continues to increase, even after interrupt occured.

Can some body tell me ; what exactly I am missing.

Thanks in advance

Sri

Parents
  • 1) Please, please, please, please do follow the posting instructions. You did not use any tags when you posted your source code, so the code is almost impossible to read. Why do you think there are a lot of information presented when you write a post? Just because someone was bored and just had to write the information?

    2) You are not clearing the interrupt controller.

        T0IR        = 1;                            // Clear interrupt flag
        VICVectAddr = 0xff;                         // Acknowledge Interrupt
    

    3 Why did you do T0IR |= 1 instead of T0IR = 1?

    The datasheet (chapter 23, paragraph 6.1, says:
    "Writing a logic one to the corresponding IR bit will reset the interrupt."
    "Writing a zero has no effect."

    By doing T0IR |= 1 instead of just T0IR = 1, you force are read/modify/write operation which is way slower.

    And you get another issue. If the T0IR have multple bits set, you will clear all bits, even if your ISR haven't handled them. They may have been set between the time you entered the ISR and the time you acknowledged/cleared them.

    With T0IR = the_bits_that_have_been_handled; your ISR will be called again in case a new interrupt situation has occurred that you missed.

    If you really want to clear any bits, without caring about if they have been handled or not, then you should do T0IR = 0xff; It's never meaningful to do a read/modify/write for that register.

Reply
  • 1) Please, please, please, please do follow the posting instructions. You did not use any tags when you posted your source code, so the code is almost impossible to read. Why do you think there are a lot of information presented when you write a post? Just because someone was bored and just had to write the information?

    2) You are not clearing the interrupt controller.

        T0IR        = 1;                            // Clear interrupt flag
        VICVectAddr = 0xff;                         // Acknowledge Interrupt
    

    3 Why did you do T0IR |= 1 instead of T0IR = 1?

    The datasheet (chapter 23, paragraph 6.1, says:
    "Writing a logic one to the corresponding IR bit will reset the interrupt."
    "Writing a zero has no effect."

    By doing T0IR |= 1 instead of just T0IR = 1, you force are read/modify/write operation which is way slower.

    And you get another issue. If the T0IR have multple bits set, you will clear all bits, even if your ISR haven't handled them. They may have been set between the time you entered the ISR and the time you acknowledged/cleared them.

    With T0IR = the_bits_that_have_been_handled; your ISR will be called again in case a new interrupt situation has occurred that you missed.

    If you really want to clear any bits, without caring about if they have been handled or not, then you should do T0IR = 0xff; It's never meaningful to do a read/modify/write for that register.

Children
No data