為輸出電平! 定時(shí)器,AD,看門狗全部禁止(燒錄FUSE選項(xiàng)時(shí)也有禁止); 然后寫掉電模式指令后, 燒錄程序到MCU后, MCU不能進(jìn)入掉電模式, 仍然以200MS 周期復(fù)位一次(非喚醒, 如果是正常喚醒LEDE會(huì)翻轉(zhuǎn),但LEDE一直為熄滅狀態(tài)), LEDF 指示燈 不停 翻轉(zhuǎn); 而用AVRSTUDIO軟件模擬時(shí)卻沒(méi)有這個(gè)問(wèn)題.
請(qǐng)教一下 這是怎么引起的. 哪位兄弟能不能提供一個(gè)可以進(jìn)入掉電模式的程序段給我學(xué)習(xí)一下. 謝謝!!
void port_init(void)
{
PORTB = 0x00;
DDRB = 0xFF;
PORTC = 0x00; //m103 output only
DDRC = 0x7F;
PORTD = 0x00;
DDRD = 0xFF;
}
//call this routine to initialize all peripherals
void init_devices(void)
{
//stop errant interrupts until set up
CLI(); //disable all interrupts
port_init();
MCUCR = 0x00;
EICRA = 0x00; //extended ext ints
EIMSK = 0x00;
TIMSK0 = 0x00; //timer 0 interrupt sources
TIMSK1 = 0x00; //timer 1 interrupt sources
TIMSK2 = 0x00; //timer 2 interrupt sources
PCMSK0 = 0x00; //pin change mask 0
PCMSK1 = 0x00; //pin change mask 1
PCMSK2 = 0x00; //pin change mask 2
PCICR = 0x00; //pin change enable
PRR = 0xFF; //power controller
SEI(); //re-enable interrupts
//all peripherals are now initialized
}
//=============================
main()
{
if(i!=0x55)
{ init_devices();
}
i = 0x55 ;
watchdog_init();
CLI();
ADCSRA = 0x00;
EIMSK = 0x00; //外部中斷X允許
EIMSK=0X00;
PCIFR = 0X07; //清中斷符
WDR();
WDTCSR |= (1<
PRR=0XfF;
SMCR=0X05;
waitsleep:
PORTB^=(1<
PORTD^=(1<
SMCR&=~(1<