/*
Experiment 12:
AVR internal door watch experiment.
1. Experiment of watching the door. Feed the dog periodically in the main program, and start the watchdog by pressing a button to make the program loop infinitely.
2. Internal 1 M crystal oscillator, the program adopts single-task mode and software delay.
3. To conduct this experiment, please plug in all 8 short-circuit blocks of JP1 and JP3, and the short-circuit block of JP7 (LED_EN).
4. Through this experiment, you can understand the settings of the watchdog and how to feed the watchdog.
*/
#include "iom16v.h"
#include /*Delay function*/ void delay_ms(unsigned char i) { unsigned char a, b; for (a = 1; a < i; a++) { for (b = 1; b; b++) { ; } } } void main(void) { DDRA = 0x00;/*Direction input*/ PORTA = 0xFF;/*Turn on pull-up*/ DDRB = 0xFF;/*Direction output*/ PORTB = 0xFF;/*Level setting*/ DDRC = 0x00; PORTC = 0xFF; DDRD = 0x00; PORTD = 0xFF; PORTB = 0x00; WDR();/*Feed the dog*/ delay_ms(250); WDR();/*Feed the dog*/ delay_ms(250); PORTB = 0xFF; WDTCR |= ((1 << WDTOE) | (1 << WDE));/*Startup timing*/ WDTCR = ((1<< WDE) | (1 << WDP2) | (1 << WDP1));/*Set the cycle to 1S*/ while (1) { delay_ms(250); WDR();/*Feed the dog*/ PORTB ^= (1 << 0);/*PB0 level inversion*/ while(PINA != 0xFF);/*Detect key press*/ } }
Previous article:Building your own AVR RTOS (Part 7: Preemptive Kernel)
Next article:Building your own AVR RTOS (Part 6: Scheduling)
- 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
- A comprehensive look at Sub-6Ghz massive MIMO infrastructure
- Detailed explanation of the schematic diagram of each part of the flyback switching power supply UC3842 protection circuit
- Several indoor wireless positioning technologies
- NXP Rapid IoT Review] +4. Learn the design ideas of POWER circuits
- 1. The relationship between the register value and the analog signal voltage. Different voltage values have different states in the register...
- Understanding the configuration of C2000 series CMD files
- A batch of STM32F103RBT6 10 packages in stock
- [Xiaomeige SoC] Generate preloader under win10 and report Failed to open gdrive/…/uboot-socfpga.tar.gz
- PYPL October 2022 Rankings
- Looking for a voltage detection circuit or chip, 3v to 12v