In the Function_define.h file
#ifdef FOSC_160000 // if Fsys = 16MHz
#define TIMER_DIV12_VALUE_10us 65536-13 //13*12/16000000 = 10 uS, // Timer divider = 12 for TM0/TM1
#define TIMER_DIV12_VALUE_100us 65536-130 //130*12/16000000 = 10 uS, // Timer divider = 12
#define TIMER_DIV12_VALUE_1ms 65536-1334 //1334*12/16000000 = 1 mS, // Timer divider = 12
16M clock, after 12 division, the timer period is 16/12 us, so 1ms=1000*16/12 is about 1334
Each unit is 1ms
void Timer0_Delay1ms(UINT32 u32CNT)
{
clr_T0M; //T0M=0, Timer0 Clock = Fsys/12 Timer 0 12 division
TMOD |= 0x01; //Timer0 is 16-bit mode 16-bit timer/counter
set_TR0; //Start Timer0
while (u32CNT != 0)
{
TL0 = LOBYTE(TIMER_DIV12_VALUE_1ms); //Find define in "Function_define.h" "TIMER VALUE"
TH0 = HIBYTE(TIMER_DIV12_VALUE_1ms); //Set the corresponding values for the high 8 bits and the low 8 bits
while (TF0 != 1); //Check Timer0 Time-Out Flag Wait for overflow
clr_TF0; //Clear overflow
u32CNT--;
}
clr_TR0; //Stop Timer0 Timer 0 stops
}
Previous article:Nuvoton MS51FB9AE development environment construction
Next article:N76E003AT20 MCU serial port 0 debugging
- 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
- CGD and Qorvo to jointly revolutionize motor control solutions
- CGD and Qorvo to jointly revolutionize motor control solutions
- Keysight Technologies FieldFox handheld analyzer with VDI spread spectrum module to achieve millimeter wave analysis function
- Infineon's PASCO2V15 XENSIV PAS CO2 5V Sensor Now Available at Mouser for Accurate CO2 Level Measurement
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- A new chapter in Great Wall Motors R&D: solid-state battery technology leads the future
- Naxin Micro provides full-scenario GaN driver IC solutions
- Interpreting Huawei’s new solid-state battery patent, will it challenge CATL in 2030?
- Are pure electric/plug-in hybrid vehicles going crazy? A Chinese company has launched the world's first -40℃ dischargeable hybrid battery that is not afraid of cold
- What exactly are those “special pads” on PCB boards used for?
- CC2640 power configuration modification
- Is there a conflict between CircuitPython and MicroPython?
- What is the relationship between embedded and microcontroller?
- Problems encountered in debugging Pingtouge's scenario-based Bluetooth Mesh
- Can S0 on the coil be understood as an ordinary auxiliary relay?
- Noise Suppression Basics Tutorial - Noise Suppression in Differential Transmission
- What content do you most want to see about Bluetooth?
- [Erha Image Recognition Artificial Intelligence Vision Sensor] 4. Object Recognition and Line Patrol Function Test
- Chip war: salary increase starts at 50%, engineers are more expensive than bosses