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

match register on lpc2378

Hi all.
I want to use all 4 T0MRx in my program.
whit TxMCR we can set what happen after T0MRx match with T0TC.
my problem is here : I could wrote code for 1 T0MRx , but I can't write code for all of them.

one point : timerx jast have one isr , how i can use all of 4 T0MRx interrupt ?
thanks.

oh , the MCU is lpc2378.

Parents Reply Children
  • it's my code :

    #include <lpc23xx.h>
    
    #define     LCD_PORT_0
    #define     LCD_RS 25
    #define         LCD_E 24
    #define         LCD_DB4 23
    #define         LCD_DB5 22
    #define         LCD_DB6 21
    #define         LCD_DB7 20
    #include <lcd.h>
    
    
    
    
    
    
    int i=0;
    int j=10000;
    
    void timer0_isr(void) __irq{
    
    
    if(T0MR0==T0TC)
    i++;
    else if(T0MR1==T0TC)
    j--;
    
    
    T0IR=3;
    VICVectAddr=0;
    T0TCR=1;
    }
    
    
    
    int main(){
    SCS=1;
    lcd_init();
    lcd_clear();
    
    //timer0 setting
    T0TCR=2;                           // reset counter , disable counter
    T0CTCR=0;             // set T/C for Timer
    T0PR=0;              // no prescale
    T0MR0=1500000;
    T0MR1=3000000;
    T0MCR=63;
    T0TCR=1;                   //enable counter
    
    //interrupt setting
    VICIntSelect=0;          // set timer0 interrupt on IRQ mood
    VICIntEnable=1 << 4;               // enable interrupt for timer0
    VICVectAddr4=(unsigned long) timer0_isr;         //set label for jump when T0MR0 is match with T0TC
    
    
    //LEDs setting
    PINSEL6=0;
    FIO3DIR0=255;
    
    //main loop
    
    while(1){
    
    lcd_gotoxy(1,1);
    lcd_puts(i);
    lcd_putsf("      ");
    lcd_gotoxy(2,1);
    lcd_puts(j);
    lcd_putsf("    ");
    
    
    }}