您的位置 首页 制造

ICCAVR看门狗

tools-ApplicationBuilder.WatchdogTimer选中enable后。右边选时钟。自动生成WatchdogTimer所需的数据//ICC-AVRapplicationbui.

tools -Application Builder.

Watchdog Timer选中enable后。右边选时钟。主动生成Watchdog Timer所需的数据

//ICCAVR application builder : 2009-11-1 12:59:57
// Target : M16
// Crystal: 4.0000Mhz

#include
#include

void port_init(void)
{
PORTA = 0x00;
DDRA = 0x00;
PORTB = 0x00;
DDRB = 0x00;
PORTC = 0x00; //m103 output only
DDRC = 0x00;
PORTD = 0x00;
DDRD = 0x00;
}

//Watchdog initialize
// prescale: 2048K
void watchdog_init(void)
{
WDR(); //this prevents a timout on enabling
WDTCR = 0x0F; //WATCHDOG ENABLED – dont forget to issue WDRs
}

//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;
G%&&&&&%R = 0x00;
TIMSK = 0x00; //timer interrupt sources
SEI(); //re-enable interrupts
//all peripherals are now initialized
}

声明:本文内容来自网络转载或用户投稿,文章版权归原作者和原出处所有。文中观点,不代表本站立场。若有侵权请联系本站删除(kf@86ic.com)https://www.86ic.net/bandaoti/zhizao/272924.html

为您推荐

联系我们

联系我们

在线咨询: QQ交谈

邮箱: kf@86ic.com

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

返回顶部