N76E003---Input capture

Publisher:快乐球球Latest update time:2022-07-06 Source: csdnKeywords:N76E003 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

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 }


Keywords:N76E003 Reference address:N76E003---Input capture

Previous article:N76E003-SPI MASTER
Next article:How to use N76E003 ADC

Recommended ReadingLatest update time:2024-11-23 16:33

MCU N76E003 EC12 Encoder
sbit EC_B = P0 ^ 0; // encoder P0.0 port sbit EC_A = P1 ^ 3; // encoder P1.3 port static uint8_t EC_A_Val = 0, EC_B_Val = 0; static uint8_t EC_A_old = 0, EC_B_old = 0; /********************************************* Function name: EncoderReading Function: Read encoder data Formal parameters: Return value: 0--no action
[Microcontroller]
How to use N76E003 serial port ISP
1. Required hardware: N76E003 development board, USB2TTL serial cable, NU-LINK programmer 2. Required software. Official website ISP source code. The corresponding project is as shown in the figure. https://github.com/OpenNuvoton/N76E003-BSP 3. Just like a normal project, use NU-LINK to burn the project into the IC. 4
[Microcontroller]
How to use N76E003 serial port ISP
N76E003 Sharp GP2Y1010 PM2.5
First, let's look at the connection diagram between the internal structure of the sensor and the microcontroller. As shown in the figure below, the I/O pins 3 and 5 are actually used. Pin 3 is the pin for PWM driving the LED flashing frequency, and the timing can be seen below. Pin 5 Vo is the output voltage value of
[Microcontroller]
N76E003 Sharp GP2Y1010 PM2.5
N76E003 ADC Multi-channel Sampling
First, let's take a look at how the ADC of the N76E003 microcontroller works. From the figure below, we can see that the ADCHS register determines which channel's ADC is currently in use. Next, let's take a look at the specific meaning of the registers Next is the relevant macro definition contained in the N76e003
[Microcontroller]
N76E003 ADC Multi-channel Sampling
Latest Microcontroller Articles
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号