Yahoo Groups archive

Lpc2000

Index last updated: 2026-04-28 23:31 UTC

Message

Timer start with different MCR

2005-02-02 by sifiland

I would like to release timer interrupt in 3 different time 
intervals.  
1. 625 Hz
2. 450 Hz
3. 300 Hz

I always get 680Hz timer interrupt, which is to it wrongly?  
Thanks.


Procesor: LPC2294
Pclk = 16 MHz

void    timerstart(void)
{
static unsigned char ucTimerMode = 0;
    if(guiTimerStart == 1)
    {
        //T0TC = 0;
        //T0MCR = 0x03;
        //T0TCR = 1;
        
        T0TCR = 0;      // Timer0 ausschalten
        T0TCR = 2;      // Reset timer 0.
        T0TCR = 0;
        T0IR = 0xff;    // Clear timer 0 interrupt line.
        T0PR = 0;       // Prescaler is set to no division.  
        switch(ucTimerMode)
        {
            case 0:
                T0MR0 = 0x6400;  // Count up to this value.
                ucTimerMode++;
                break;
            case 1:
                T0MR0 = 0x8AE3;  // Count up to this value.
                ucTimerMode++;
                break; 
            case 2:
                T0MR0 = 0xCF08;  // Count up to this value.
                ucTimerMode = 0;
                break;                        
        }
        
        T0MCR = 3;      // Reset and interrupt on MR0
        T0CCR = 0;      // Capture is disabled.
        T0EMR = 0;      // No external match output.
        T0TCR = 1;
        
       guiTimerStart = 0;
    }
}

void    Timer0Int(void) 
{
    if((guiOn != 0)||(guiOff != 0))
    {

        on();
        off();

        __disable_interrupt();              // Alle Interrupt sperren

        //Code

        // Enable interrupts.
        Enable_IRQ();
    }
    else
    {   
        T0TCR = 2;      // Timer0 stoppen
        T0IR = 0xFF;
    }
}

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.