• 回复
  • 收藏
  • 点赞
  • 分享
  • 发新帖

atmega48v不能进入掉电模式

我用ATMEGA48v , ICC-AVR写了这样一段程序, IO 不允许中断功能,全部 初始
为输出电平!  定时器,AD,看门狗全部禁止(烧录FUSE选项时也有禁止); 然后写掉电模式指令后, 烧录程序到MCU后, MCU不能进入掉电模式, 仍然以200MS 周期复位一次(非唤醒, 如果是正常唤醒LEDE会翻转,但LEDE一直为熄灭状态), LEDF 指示灯 不停 翻转; 而用AVRSTUDIO软件模拟时却没有这个问题.

请教一下 这是怎么引起的. 哪位兄弟能不能提供一个可以进入掉电模式的程序段给我学习一下. 谢谢!!


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< WDTCSR=0X00;


PRR=0XfF;
SMCR=0X05;

waitsleep:
PORTB^=(1< asm ("sleep");
PORTD^=(1< goto waitsleep;

    SMCR&=~(1<    SMCR&=~(1<
全部回复(1)
正序查看
倒序查看
baipl5155
LV.1
2
2009-10-26 22:40
还请大家赐教!!
0
回复