AVR watchdog is a hardware unit. When the program runs "fly" for some reason, it resets the program. Just like a puppy watching a door. //Watchdog iniTIalize // prescale: 2048K Void watchdog_init(void) { WDR(); //this prevents a TImout on enabling WDTCR = 0x0F; //WATCHDOG ENABLED - dont forget to issue WDRs } The above is a watchdog initialization program generated by ICC's App Builder. These statements do not achieve the purpose of initializing the watchdog. You need to add a WDTCR = 0x1F in the middle. The last line of code reminds the dog owner, don't forget to clear the watchdog timer (feed the dog) in time, otherwise the puppy will bite. A relatively independent count automatically restarts the hardware components of the microcontroller. If it is enabled, it will not clear its count value within a certain period of time, it will reach the highest value of the count and overflow, and then it will direct the microcontroller to restart. So to properly add the watchdog instructions in your program, once your MCU program has a problem, of course, you can't automatically clear the watchdog as your program originally set, which is often said. Run away, this time the watchdog will restart the microcontroller to try to solve the problem. Generally, it is only effective for problems caused by transient interference. If it is a long-term interference or hardware and software problem, the significance of the watchdog is not great. My understanding is like monitoring the security of the execution of the program. When the program is executed normally, it will give him a reset signal within his beneficial time. When the program runs away, he will not receive the reset signal within the overflow time. At this time, the watchdog will generate a system reset signal within the set time! The AVR watchdog is a soft dog and a hard dog! If the fuse is not set, it is a soft dog, because the program can be turned off, it can also be turned on. If the fuse is set, it is a hard dog, because the program can only be cleared. Can't open or close! Is WDR() added to the program; even if you "feed the dog"? Feeding the dog seems to calculate the time? How do I feed the dog every time I perform a function? If the cycle time of your cycle does not exceed the reset time of the watchdog, it is enough to feed the dog once. AVR watchdog program example, the program demonstrates the reset process of the watchdog, using the first example of the newcomer to the site, under normal circumstances, the program finally falls into an infinite loop, but in this program, the watchdog resets the microcontroller. You will see the LED flashing all the time, the same effect as the first sample program. At two points, initialize, then feed the dog, feed the dog before the watchdog bites, (feed the dog before resetting). // Watchdog reset demo program. #include #include Void port_init(void) { PORTA = 0x03; // set to output DDRA = 0x03; //High level, both LEDs are off PORTB = 0x00; DDRB = 0x00; PORTC = 0x00; DDRC = 0x00; PORTD = 0x00; DDRD = 0x00; } //Watchdog iniTIalize // prescale: 2048K //The larger the prescaler, the longer the timing, that is, it can be used for a longer time. // about 2.1s reset (according to data sheet, 2048K, 5V typical value) Void watchdog_init(void) { WDR(); //this prevents a TImout on enabling WDTCR = 0x1F; //Special attention to this is not generated by ICC, it is added later. WDTCR = 0x0F; //WATCHDOG ENABLED - dont forget to issue WDRs } / / Added a dog delay program Void Delay(void) { Unsigned char i,j; For(i=200;i>0;i--) { For(j=200;j>0;j--) ; } WDR(); //feed the dog here } //call this routine to initialize all peripherals Void init_devices(void) { //stop errant interrupts until set up CLI(); //dISAble all interrupts Port_init(); Watchdog_init(); MCUCR = 0x00; GICR = 0x00; TIMSK = 0x00; //timer interrupt sources SEI(); //re-enable interrupts //all peripherals are now initialized } Void main(void) { Unsigned int i; Init_devices(); //initialize For(i=10;i>0;i--) //See the flashing of the program { PORTA = 0x02; //1 pin is high, 0 pin is low, 0 pin is lit Delay(); //delay PORTA = 0x01; //0 is high, 1 is low, 1 is lit Delay(); //delay } While(1) // Under normal circumstances, the program will fall into this loop all the time. //The watchdog can reset the microcontroller, the program re-runs, and we see the LED flashing. //If you add WDR() here; feed the dog, the microcontroller will not reset. } Supplement, special instructions Enable the watchdog can not use |=, must be directly assigned =. There is also a data sheet saying: Changing the timer overflow time and disabling (already enabled) the watchdog timer requires a specific time series: 1. Write "1" to WDCE and WDE in the same instruction, even if WDE is already "1". 2. Set WDE and WDP to the appropriate values ​​within the next 4 clock cycles, and WDCE writes "0". So before WDTCR=0x0E; add a sentence WDTCR=0x1F; Void watchdog(void) { WDR (); / / watchdog count clear
ZGAR Vape Pods 1.0
ZGAR electronic cigarette uses high-tech R&D, food grade disposable pods and high-quality raw material. A new design of gradient our disposable vape is impressive.We equip with breathing lights in the vape pen and pods.
Our team has very high requirements for product quality, taste allocation and packaging design. Designers only use Hong Kong designers, e-cigarette liquid only imports from the United States, materials are food grade, and assembly factory wants medical grade without ground workshop.
We offer best price, high quality Pod System Vape,Pods Systems Touch Screen,Empty Pod System, Pod Vape System,Disposable Pod device,Vape Pods to all over the world.
ZGAR Vape 1.0 Pods,ZGAR Vape Pods 1.0 ,Pod Systems,Atomizer, E-cigarette, Empty Pod Vape Manufacturer and Supplier in China Zgar International (M) SDN BHD , https://www.zgarvapepen.com