Timing formula: Time = PRE*(MAX-TCNT0+1)/F_cpu unit S, where PRE is the frequency division number
#include
#include
void port_init(void)
{
PORTA = 0xFF;
DDRA
PORTB = 0xFF;
DDRB
PORTC = 0xFF; //m103 output only
DDRC
PORTD = 0xFF;
DDRD
}
//TIMER0 initialize - prescale:8/256
// WGM: Normal
// desired value: 1mSec/20ms
// actual value:
void timer0_init(void)
{
TCCR0 = 0x00; //stop
//TCNT0 = 0x83; //set count T=PRE*(MAX-TCNT0+1)/F_cpu=8*(255-130)/1MHz=1ms
TCNT0 = 0xB2; //set count T=PRE*(MAX-TCNT0+1)/F_cpu=256*( 255-178+1)/1MHz=19.968ms
OCR0
Previous article:This is the AVR watchdog timeout
Next article:12864 LCD (AVR_Mega128) header file
- Popular Resources
- Popular amplifiers
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
- Huawei's Strategic Department Director Gai Gang: The cumulative installed base of open source Euler operating system exceeds 10 million sets
- Download from the Internet--ARM Getting Started Notes
- Learn ARM development(22)
- Learn ARM development(21)
- Learn ARM development(20)
- Learn ARM development(19)
- Learn ARM development(14)
- Learn ARM development(15)
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
- Repost - I have never seen the cross-section of these cable interfaces before
- Help with digital voltmeter design issues
- Kubo MS6908 perfect PIN2PIN replacement MP6908
- Research and FPGA Design of Image Scaling Algorithm
- Decoding Analysis and Simulation of 315Mhz and 433Mhz Wireless Remote Control Signals
- 【AT32WB415 Review】Bluetooth Communication and Test 2
- [Dry Goods] Analysis of Commonly Used Formulas in Power Supply Design
- Official announcement: "Keysight Thanksgiving Month", where hundreds of instruments are given away every year, is here again!
- 28335 development board problem
- 【Project source code】CRC32 calculation based on FPGA