Input Capture
According to the chip manual, timer 2 can be used as input capture. The setup is very simple. The official also provides macros for us to use.
void Time2_cap_init(void)
{
/******* Input capture CF settings *********/
Set_All_GPIO_Quasi_Mode;
P04_Input_Mode;
//P04 = 1;
TIMER2_CAP0_Capture_Mode; //Timer 2 enables input capture function
IC3_P04_CAP0_RisingEdge_Capture; //P04 pin, capture mode: rising edge capture
set_ECAP; // Enable input capture interrupt
set_TR2;
set_EA;
}
Processing Function
My processing function is very simple. After capturing a rising edge, it changes to a falling edge trigger, that is, it captures a pulse.
1 void Capture_ISR (void) interrupt 12
2 {
3 static char state;
4
5 if(state == 1)
6 {
7 IC3_P04_CAP0_RisingEdge_Capture; //Start rising edge capture
8 pulse_cnt++; //Capture times plus 1
9
10 state = 0;
11 }
12 else //First capture rising edge
13 {
14 IC3_P04_CAP0_FallingEdge_Capture; //Start falling edge capture
15 state = 1;
16
17 }
18 clr_CAPF0;
19
20
twenty one }
Previous article:N76E003-SPI MASTER
Next article:How to use N76E003 ADC
Recommended ReadingLatest update time:2024-11-23 16:33
- Popular Resources
- Popular amplifiers
- Naxin Micro and Xinxian jointly launched the NS800RT series of real-time control MCUs
- How to learn embedded systems based on ARM platform
- Summary of jffs2_scan_eraseblock issues
- Application of SPCOMM Control in Serial Communication of Delphi7.0
- Using TComm component to realize serial communication in Delphi environment
- Bar chart code for embedded development practices
- Embedded Development Learning (10)
- Embedded Development Learning (8)
- Embedded Development Learning (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Intel promotes AI with multi-dimensional efforts in technology, application, and ecology
- ChinaJoy Qualcomm Snapdragon Theme Pavilion takes you to experience the new changes in digital entertainment in the 5G era
- Infineon's latest generation IGBT technology platform enables precise control of speed and position
- Two test methods for LED lighting life
- Don't Let Lightning Induced Surges Scare You
- Application of brushless motor controller ML4425/4426
- Easy identification of LED power supply quality
- World's first integrated photovoltaic solar system completed in Israel
- Sliding window mean filter for avr microcontroller AD conversion
- What does call mean in the detailed explanation of ABB robot programming instructions?
- STMicroelectronics discloses its 2027-2028 financial model and path to achieve its 2030 goals
- 2024 China Automotive Charging and Battery Swapping Ecosystem Conference held in Taiyuan
- State-owned enterprises team up to invest in solid-state battery giant
- The evolution of electronic and electrical architecture is accelerating
- The first! National Automotive Chip Quality Inspection Center established
- BYD releases self-developed automotive chip using 4nm process, with a running score of up to 1.15 million
- GEODNET launches GEO-PULSE, a car GPS navigation device
- Should Chinese car companies develop their own high-computing chips?
- Infineon and Siemens combine embedded automotive software platform with microcontrollers to provide the necessary functions for next-generation SDVs
- Continental launches invisible biometric sensor display to monitor passengers' vital signs
- Design of ultra-wideband high- and low-frequency nested antenna based on asymmetric radiating elements
- Negative feedback amplifier circuit design
- Disassembling the display module of Audi Q3 and A4L
- The netizens who commented and downloaded the content this time are so excellent, and some good information has surfaced~all of them are top-notch information!
- Hydrogen removal lasers to help
- Hiring embedded software engineer
- Design a tester for measuring resistance and inductance using a DC digital multimeter (5-digit, maximum input voltage 10V).
- On the last day of 2019, make a New Year’s wish for 2020!
- A brief summary of the operating instructions: (The following is basically nonsense, just understand it)
- Gallium Nitride Transistors Open New Frontiers in High-Speed Motor Drives