LPC1768 timer general timing

Publisher:camuspycLatest update time:2017-01-12 Source: eefocusKeywords:LPC1768 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

//The basic timing functions of other channels can be implemented here

void Time0Mr0Init(u32 arr,u32 psc)

{

     LPC_SC->PCONP |= (1<<1); //Turn on power control

     LPC_TIM0->TCR |= (1<<1); //Reset timer

     LPC_TIM0->MR0 = psc; //Compare the match register with the timer counter value

     LPC_TIM0->IR |= 0XFF; // Clear all interrupt flags

     LPC_TIM0->MCR |= ((1<<1)|(1<<0)); //When MR0 matches TC value, an interrupt will be generated and TC will be reset

     LPC_TIM0->PC = 0X00;

     LPC_TIM0->PR = arr-1; //Pre-scaling

     LPC_TIM0->TCR = (1<<0); //Start timer

     NVIC_EnableIRQ(TIMER0_IRQn); /* enable irq in nvic */

}

 

void TIMER0_IRQHandler(void)

{

     if( LPC_TIM0->IR &0x01)

     {

         Time0Mr0CallBack;

     }

     LPC_TIM0->IR |= (1<<0); // Clear interrupt flag

 }


Keywords:LPC1768 Reference address:LPC1768 timer general timing

Previous article:System clock of LPC1768
Next article:PWM usage of LPC1768

Recommended ReadingLatest update time:2024-11-16 14:34

Understanding of S3C6410 timer related codes in Linux kernel
This article describes the relevant codes in time.c based on the mini6410 platform, mainly describing the understanding of some codes. Paste the code first: 1 /* we use the shifted arithmetic to work out the ratio of timer ticks 2 * to use cs, as often the peripheral clock is not a nice ev
[Microcontroller]
Teach you how to write S12XS128 program (25) --Timer module application example 2
Output Compare (OC) programming steps: Initialization function TIOS---Select the working mode as OC TCx---Channel x's OC register is initialized and enters the first interrupt after N seconds TCTLx---Set the corresponding bit input capture mode (x=1, 2, the upper four bits are 1, the lower four bits are 2) T
[Microcontroller]
LPC1768 Clock and Timer
The clock consists of 4 parts 1: CLKSRC: 01 in the example    Select the clock source of PLL0 as follows:   00 Select the internal RC oscillator as the clock source of PLL0 (default)   01 Select the main oscillator as the clock source of PLL0   10 Select the RTC oscillator as the clock source of PLL0   11 Reserved, do
[Microcontroller]
LPC1768 Clock and Timer
PIC12 series TIMER0 timer initialization settings
The Timer0 module is an 8-bit timer/counter with the following features: • 8-bit Timer/Counter Register (TMR0) • 8-bit prescaler (shared with watchdog timer) • Programmable internal or external clock source • Programmable external clock edge selection • Interrupt on overflow /*****************************************
[Microcontroller]
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号