Timer 1 is a 16-bit timer with timer/counter/pulse width modulation functions. It has 3 individually programmable input capture/output comparison channels, each of which can be used as a PWM output or to capture the edge time of the input signal (for more information on what input capture/output comparison is and how to implement PWM output, readers can refer to the CC2530 Chinese manual). The timer has a very important concept: operating mode. The operating modes include: free-running mode, modulo mode, and up-down mode. The design of the free-mode program for timer Timer1 is as follows:
#include #define uint unsigned int #define uchar unsigned char #define RLED P1_0 #define YLED P1_1 uint counter=0; //Count the number of overflows uint TempFlag; //Used to mark whether to flash void Initial(void); void Delay(uint); /**************************** //Normal delay program ***************************/ void Delay(uint n) { uchar i; while(n--) { for(i=200;i>0;i--); } } /**************************** // Initialization program ***************************/ void Initial(void) { // Initialize P1 P1DIR = 0x03; //P10 P11 is output RLED = 1; YLED = 1; // Turn off LED T1CTL = 0x05; //00001101 8-frequency automatic reload } /******************************* //Main function ***************************/ void main(void) { static unsigned char cnt = 0; Initial(); //Call the initialization function RLED = 0; // Turn on the red LED while(1) //Query overflow { if(IRCON > 0) { IRCON = 0; // Clear overflow flag cnt++; if(cnt == 15) { cnt = 0; RLED = !RLED; } } } } The main registers used in this program are: T1CTL, IRCON. The value set in the T1CTL register is 0x05. According to the manual, this register configures the frequency division to 8, that is, f/8, and the mode is set to free mode and Free-running. The count value will be counted from 0x0000-0xFFFF. The second bit in IRCON is the interrupt flag bit of timer 1.
Previous article:CC2530 Bare Metal Programming Series Notes 5--Interrupts
Next article:CC2530 bare metal programming series notes 2--Timer Timer1 mode program interrupt mode
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Sn-doped CuO nanostructure-based ethanol gas sensor for real-time drunk driving detection in vehicles
- Design considerations for automotive battery wiring harness
- Do you know all the various motors commonly used in automotive electronics?
- What are the functions of the Internet of Vehicles? What are the uses and benefits of the Internet of Vehicles?
- Power Inverter - A critical safety system for electric vehicles
- Analysis of the information security mechanism of AUTOSAR, the automotive embedded software framework
- Brief Analysis of Automotive Ethernet Test Content and Test Methods
- How haptic technology can enhance driving safety
- Let’s talk about the “Three Musketeers” of radar in autonomous driving
- Why software-defined vehicles transform cars from tools into living spaces
- Introduction to the method of board-level online compilation and downloading of C6000 DSP code
- Cadence Circuit Design Case Analysis
- Could you please tell me which manufacturers produce magnetic resistance switches? I only found one.
- Field Effect Transistor Basics and Application Practice
- Verilog Golden Reference Guide Chinese version.pdf
- [ART-Pi Evaluation] V: ATT-Pi WiFi networking and MQTT publishing and subscription evaluation in RTT Studio environment
- A chart to understand China Telecom's "5G SA Deployment Guide"
- Art on Silicon (3)
- MSP430F5529 multi-channel PWM output control servo and motor
- Discrete Difference Amplifiers vs. Integrated Solutions