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
}
Previous article:lpc1778 commonly used io port setting functions
Next article:LPC1788---Serial port settings
Recommended ReadingLatest update time:2024-11-16 12:57
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
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Urgently looking for expert advice AD15 can not open the PCB after cracking
- Difference between LPS22HH and LPS22HB
- How to collect multiple sensor signals through one RS485 interface of industrial computer?
- Altera SoC Architecture Excerpt - What is a SoC FPGA
- EEWORLD University ---- Python 3 video tutorial
- [Rivet RVB2601 Creative Application Development Competition] Participation Award Prizes
- CCS5.5 compiler optimization issues
- Is there anyone who knows PGA460? My circuit diagram is based on PGA460PSM, but I can't get any measurement results.
- How does AD import the complete content of a DWG file, or how does AD apply copper in a ring-shaped strip area?
- 5G mobile phones bring huge opportunities to RF front-end