(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);
}

原文地址:https://www.cnblogs.com/ollie-lin/p/10794434.html

时间: 2024-10-10 05:30:28

(LPC1769) Timer Interrupt Application的相关文章

Software UART, Timer, PWM, External Interrupt

How can you add extra hardware UARTs to a 32bit TMS470 ARM7-based microcontroller at zero cost? Solution: Designers can use the high-end timer (HET) peripheral found on all Texas Instruments ARM7-based, 32-bit TMS470 microcontrollers to implement add

PIC32MZ tutorial -- 32-bit Timer

The microcontroller is PIC32MZ2048ECH144 on the PIC32MZ EC Starter Kit. This microcontroller has four 32-bit synchronous timers are available by combining Timer2 with Timer3, Timer4 with Timer5, Timer6 with Timer7, and Timer8 with Timer9. The 32-bit

Linux时间子系统(十七) ARM generic timer驱动代码分析

一.前言 关注ARM平台上timer driver(clocksource chip driver和clockevent chip driver)的驱动工程师应该会注意到timer硬件的演化过程.在单核时代,各个SOC vendor厂商购买ARM core的IP,然后自己设计SOC上的peripherals,这里面就包括了timer的硬件.由于没有统一的标准,各个厂商的设计各不相同,这给驱动工程师带来了工作量.然而,如果仅仅是工作量的话就还好,实际上,不仅仅如此.linux的时间子系统要求硬件t

.net Timer定时执行

System.Timers.Timer可以实现数据库定时更新的功能 Global.asax void Application_Start(object sender, EventArgs e) { // 在应用程序启动时运行的代码 System.Timers.Timer timer = new System.Timers.Timer(1000); timer.Elapsed += new System.Timers.ElapsedEventHandler(AddCount); //AddCoun

Logical partitioning and virtualization in a heterogeneous architecture

A method, apparatus, and computer usable program code for logical partitioning and virtualization in heterogeneous computer architecture. In one illustrative embodiment, a portion of a first set of processors of a first type is allocated to a partiti

Create a DAC from a microcontroller&#39;s ADC

Few microcontrollers include a DAC. Although you can easily find an inexpensive DAC to control from your microcontroller, you can use unused peripherals instead of adding parts. Fortunately, you can convert a microcontroller's ADC channel along with

Single-stack real-time operating system for embedded systems

A real time operating system (RTOS) for embedded controllers having limited memory includes a continuations library, a wide range of macros that hide continuation point management, nested blocking functions, and a communications stack. The RTOS execu

Uniform synchronization between multiple kernels running on single computer systems

The present invention allocates resources in a multi-operating system computing system, thereby avoiding bottlenecks and other degradations that result from competition for limited resources. In one embodiment, a computer system includes resources an

3-Transport Layer

?Please indicate the source: http://blog.csdn.net/gaoxiangnumber1 Welcome to my github: https://github.com/gaoxiangnumber1 3.1 Introduction and Transport-Layer Services A transport-layer protocol provides for logical communication between application