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

Timer

Hi!!

I have a problem with timer. I have MCB2300 board with lpc2378.

In aplication I using RTL kernel, which use TIMER0.

Now I would like to have own timer TIMER3.
I set:


void timer3_irq (void) __irq {

    T3IR |= 0x08;

    LED_out(0x49);

    VICVectAddr = 0;
}


void timer_init(void)
{
    T3MR3  = 0x00003840; //set match channel 3 on 5ms
    T3MCR  = 0x600;      //Match register 3 enable

    //IRQ
    VICVectAddr27 = (unsigned long)timer3_irq;
    VICVectCntl27 = 4; //priority

    VICIntEnable |= 1<<27;

    //reset
    T3TCR = 0x00000003;

    //enable timer
    T3TCR = 0x00000001;
}

.

Have I set wrong?

Thanke for your help

Peter Kic

Parents
  • Hello Peter Kic,

    Please code it like below than it will work.

    __irq void timer3_irq (void) {
    
      T3IR = 0x08;
    
      LED_Out(0x49);
    
      VICVectAddr = 0;
    }
    
    
    void timer_init(void)
    {
        PCONP |= (1 << 23);    //enable power to TIM3
    
        T3MR3  = 0x00011999; //set match channel 3 on 1ms = 12000-1 at 12.0 MHz
        T3MCR  = 0x600;      //Match register 3 enable
    
        //IRQ
        VICVectAddr27 = (unsigned long)timer3_irq;
        VICVectCntl27 = 4; //priority
    
        VICIntEnable |= 1<<27;
    
        //reset
        T3TCR = 0x00000003;
    
        //enable timer
        T3TCR = 0x00000001;
    }
    

    If have tested it on a MCB2300.
    Maybe the problem was that the __irq keyword was not at the beginning of the line.

    Best Regards,
    Martin Guenther

Reply
  • Hello Peter Kic,

    Please code it like below than it will work.

    __irq void timer3_irq (void) {
    
      T3IR = 0x08;
    
      LED_Out(0x49);
    
      VICVectAddr = 0;
    }
    
    
    void timer_init(void)
    {
        PCONP |= (1 << 23);    //enable power to TIM3
    
        T3MR3  = 0x00011999; //set match channel 3 on 1ms = 12000-1 at 12.0 MHz
        T3MCR  = 0x600;      //Match register 3 enable
    
        //IRQ
        VICVectAddr27 = (unsigned long)timer3_irq;
        VICVectCntl27 = 4; //priority
    
        VICIntEnable |= 1<<27;
    
        //reset
        T3TCR = 0x00000003;
    
        //enable timer
        T3TCR = 0x00000001;
    }
    

    If have tested it on a MCB2300.
    Maybe the problem was that the __irq keyword was not at the beginning of the line.

    Best Regards,
    Martin Guenther

Children
No data