AVR Programming _ How to reset the AVR by software? Go

Source: Internet
Author: User

Source: http://blog.sina.com.cn/s/blog_493520900100bpos.html

Question
How to reset the AVR via software?
Answer
if you want to reset the AVR by software, you should use the internal watchdog. Simple to enable it and let it overflow. When the watchdog is triggered, the program counter returns to 0, clearing all registers and other tasks that are being performed, which has the same effect as lowering the reset foot down.

You should not handle:--connect the external reset pin with another AVR pin. At a short reset time, the AVR pin will fail in three states, which will invalidate reset. --Jump to program address 0, skip to program address 0, this will not erase all registers, so you will not get a full "reset".

The following is an example code (GCC) for every 30mS reset of the AVR:

#include <avr/io.h>

#include <avr/wdt.h>

int main (void)

{

Wdt_enable (WDTO_30MS);

while (1) {};

}

Or you can generate a macro:

#include <avr/io.h>

#include <avr/wdt.h>

#define RESET_AVR () wdt_enable (wdto_30ms); while (1) {}

int main (void)

{

RESET_AVR ();

}

AVR Programming _ How to reset the AVR by software? Go

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.