(LPC1769) Timer Interrupt Application

Posted ollie-lin

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了(LPC1769) Timer Interrupt Application相关的知识,希望对你有一定的参考价值。

void TIMER0_IRQHandler (void)
{
    if(LPC_TIM0->IR & 0x01)
    {
        LPC_GPIO1->FIOPIN ^= (1 << 14);
        LPC_TIM0->IR = 0x01;
    }
}

/*
 *  CPU : LPC1769
 *  Operate Frequency : 120MHz
 *  Timer Interrupt Example :
 *        TCR : Counter Enable/Disable
 *        PR : PreScale register
 *        MR0 : when TC(timer counter) match MR0. the cup action are to generator an interrupt, reset the TC
 *        or stop the timer.
 *        IR : if an interrupt is generated that the corresponding bit in the IR will be high.
 *        writing a 1 to corresponding IR bit will reset the interrupt.
 *        writing a 0 has no effect.
 *        MCR : it will be control timer function that interrupt enable/disable. reset TC if MR0 matchit.
 *
 * */
int main(void)
{
    CFWInit();
    LPC_GPIO1->FIODIR |= (1<<14);
    LPC_GPIO1->FIOPIN &= ~(1<<14);
    LPC_SC->PCONP |= 1 << 1;                /* power control --> power saving function */
    LPC_SC->PCLKSEL0 |= (0x01 << 2);        /* Enable Timer0 peripheral clock */
    LPC_TIM0->TCR = 0x02;                     /* reset timer */
    LPC_TIM0->PR = 0x00;                     /* set prescaler to zero */
    LPC_TIM0->MR0 = 119;                     /* set the count value */
    LPC_TIM0->IR = 0xff;                     /* reset all interrupts */
    LPC_TIM0->MCR = 0x03;                     /* stop timer on match */
    NVIC_EnableIRQ(TIMER0_IRQn);
    LPC_TIM0->TCR = 0x01;                     /* start the timer */
    while(1);
}

 

以上是关于(LPC1769) Timer Interrupt Application的主要内容,如果未能解决你的问题,请参考以下文章

用于互联网连接的 LPC 1769 以太网 MAC

LPC1769 CAN的自测试模式

LPC2105单片机解密型号

单片机中的Timer0Interrupt(void) interrupt 1啥意思?

lpc1768这样配置定时器pclk是多少?

单片机中void Timer0_isr(void) interrupt 1 using 1 怎么理解