LPC1788--TIMER match interrupt setting--register operation

Publisher:CaptivatingEyesLatest update time:2021-10-14 Source: eefocusKeywords:LPC1788  TIMER Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Simple record of LPC1788 timer match interrupt settings - direct operation through registers


#include "timer_lpc1788.h"

#include "uart_lpc1788.h"


void TIMER0_IRQHandler(void) //TIMER0 interrupt function

{

    if(((LPC_TIM0->IR) &(1<<0))==(1<<0)) //match interrupt occurs

   {

       UARTSendStr("CLOSrn");

   }

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

}


void TIMER0_Init(uint32_t clk, uint32_t howtime)

{

   LPC_SC->PCONP|=(1<<1); //Turn on TIMER0 peripheral clock


   LPC_TIM0->CTCR &=(~0x03); //Count control register

   LPC_TIM0->CTCR |=0x00; //Timer mode

//----PC=PR-----TC++

   LPC_TIM0->TC =0; //timing counter

   LPC_TIM0->PR =0; //Prescaler register

   LPC_TIM0->PC =0; //Prescaler counter


   LPC_TIM0->TCR |=(1<<1); //Timer control register--reset timer

   LPC_TIM0->TCR &=~(1<<1); //Clear reset


   LPC_TIM0->PR = (clk/1000000-1); //Pre-scaling register -- system peripheral clock/1000000 = 1us required PC value


   LPC_TIM0->IR=0xFFFFFFFF; //Clear interrupt

//--------------------

   LPC_TIM0->MR0=howtime; //match register --- how many 1us will match

   LPC_TIM0->MCR &=~(0x07); //Match control register--disable matching-reset-stop interruption

   LPC_TIM0->MCR |=(1<<0); //Enable match interrupt

   LPC_TIM0->MCR |=(1<<1); //Enable reset interrupt --TC reset when matching - recount


   NVIC_SetPriority(TIMER0_IRQn, ((0x01<<3)|0x01)); //Set timer interrupt priority


   NVIC_EnableIRQ(TIMER0_IRQn); //Timer interrupt enable


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

}

Keywords:LPC1788  TIMER Reference address:LPC1788--TIMER match interrupt setting--register operation

Previous article:lpc1778 commonly used io port setting functions
Next article:LPC1788---Serial port settings

Recommended ReadingLatest update time:2024-11-16 12:57

LPC1788---Serial port settings
LPC1788 learning serial port learning-register operation Receive data using interrupt reception --- send temporarily using direct sending --- simple register operation -- write it down and don't forget it! #include "uart_lpc1788.h" uint32_t Receive_Sign; //Receive data subscript--the number of received data uint
[Microcontroller]
AVR timer - specific use of 16-bit timer1 timer
When I first started learning, I was quite familiar with the 8-bit timer0 and timer2, but I was always confused about timer1. So I looked for some books, and a kind person translated the schematic diagram into Chinese. I recommend "Advanced AVR Microcontroller for Novices" edited by Shen Tianguo. This is the Chinese-E
[Microcontroller]
AVR timer - specific use of 16-bit timer1 timer
Linux kernel timer timer_list
The Linux kernel uses the timer_list structure as a timer.   #include "linux/timer.h" #include "linux/module.h" MODULE_LICENSE("GPL");                           // Without this sentence, although it does not affect the function, "sometimes" the program will print errors when it is executed, similar to Disabl
[Microcontroller]

Recommended posts

Unpacking a JBL wireless headset
Thespeakerisconnectedthroughthiscontact. ThebackisaBluetoothchipandnothingelse. Rumorhasitthatjblishighpricedandlowquality.Whatdoyouthink?Theyareallmasters,Iamstillanovice,let'sseehowthemastersdisass
xutong Making friends through disassembly
What knowledge should I start learning when converting power product process to design?
Iworkonpowerproducttechnology,andIammainlyresponsiblefortheearlydesignreview,prototypetrialproductionandprocessissues,aswellasfailureanalysis.However,Idon’tknowmuchaboutpowermoduledesignandsomecircuitknowledge.
长天浩瀚 Power technology
Interpretation and test application of IEC harmonic standards
Therearemanymethodsforanalyzingharmonics.Inordertounifystandards,internationalordomesticstandardorganizationshaveproposeddifferentteststandardsfordifferentapplications.IECharmonicsisoneofthem.Thisarticlefocuseso
qwqwqw2088 Power technology
Git server and remote repository creation
Youcanbuilditonyourowngitserver. FreeServer github.comTheworld'slargestopensourceprojecthostingplatform gitee.comisawell-knowndomesticopensourceprojecthostingplatform. Registeragiteeaccountandcreatear
lugl4313820 Domestic Chip Exchange
What is the development trend of machine vision surface defect detection system?
InChina,theproductionvolumeofindustrialproductsisincreasingeveryyear.Therefore,usershavehigherandhigherrequirementsforproductquality.Herewearenotonlytalkingaboutperformanceissues,butalsoagoodappearance,thatis,th
Crush12138 Industrial Control Electronics
What's the difference between HDMI ports on TVs and computers?
TheHDMIportsonTVsandcomputersaresimilarinfunction,bothusedtotransmithigh-definitionvideoandaudiosignals.However,theremaybesomedifferencesintheirdesignanduse: Portlocation:ATV'sHDMIportisusuallylocatedonth
SAMZHE山泽 Integrated technical exchanges
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号