EmbeddedRelated.com
Forums
The 2024 Embedded Online Conference

POwer down mode and wake on INT0

Started by inpactmicro April 22, 2004
I cant get my ATMEGA 128 to power down and wait for an interrupt on
rising edge of d0
any ideas where I am going wrong?
this is the code Im using

//enable PORTD:0 (INT0) as interrupt input level High
EICRA = 0x03; //00000011 //rising edge on INT0
SREG = 1; //s-reg I flag
EIMSK = 0x01; //00000001 // enables external interrupt
//EIFR = 0x01;

//setup in power DOWN mode
//disable OCDN in fuses for max power saving
MCUCR = 0x28; //00101000 //SE = 1 //SM2..0 = 010
//SEI(); //enable global interrupt
asm("sei"); // sleep;
asm("sleep"); //sleep mode NOW! woken up by rising edge
asm("nop");
asm("nop");

//only wakes up when pin D) goes high
rest of program;


I think you cant let a rising edge wake up your mcu.
What i know is that it should be a low level interrupt
for your mcu to wake up. :) -jay
--- brendan.oflynn@bren... <brendan.oflynn@bren...>
wrote:
> I cant get my ATMEGA 128 to power down and wait for
an interrupt on
> rising edge of d0
> any ideas where I am going wrong?
> this is the code Im using
>
> //enable PORTD:0 (INT0) as interrupt input level
High
> EICRA = 0x03; //00000011 //rising edge on INT0
> SREG = 1; //s-reg I flag
> EIMSK = 0x01; //00000001 // enables external
interrupt
> //EIFR = 0x01;
>
> //setup in power DOWN mode
> //disable OCDN in fuses for max power saving
> MCUCR = 0x28; //00101000 //SE = 1 //SM2..0 = 010
> //SEI(); //enable global interrupt
> asm("sei"); > // sleep;
> asm("sleep"); //sleep mode NOW! woken up by
rising edge
> asm("nop");
> asm("nop");
>
> //only wakes up when pin D) goes high
> rest of program;
>


__________________________________




As you can find in the Mega128 datasheet, you CAN'T wake up
from sleep using INT0/1 rising/falling edge.
You have to use INT on LEVEL. So it will works.

MArk Jordan On 22 Apr 2004 at 14:29, inpactmicro wrote:

> I cant get my ATMEGA 128 to power down and wait for an interrupt on
> rising edge of d0
> any ideas where I am going wrong?
> this is the code Im using
>
> //enable PORTD:0 (INT0) as interrupt input level High
> EICRA = 0x03; //00000011 //rising edge on INT0
> SREG = 1; //s-reg I flag
> EIMSK = 0x01; //00000001 // enables external interrupt
> //EIFR = 0x01;
>
> //setup in power DOWN mode
> //disable OCDN in fuses for max power saving
> MCUCR = 0x28; //00101000 //SE = 1 //SM2..0 = 010
> //SEI(); //enable global interrupt
> asm("sei"); > // sleep;
> asm("sleep"); //sleep mode NOW! woken up by rising edge
> asm("nop");
> asm("nop");
>
> //only wakes up when pin D) goes high
> rest of program; > Yahoo! Groups Links


Excerpt from data sheet:

The External Interrupts 3 - 0 are activated by the external pins
INT3:0 if the SREG I-flag and the corresponding interrupt mask in the
EIMSK is set. The level and edges on the external pins that activate
the interrupts are defined in Table 48. Edges on INT3..INT0 are
registered asynchronously.

for me this indicates edges ARE registered on INT0!

--- In avrclub@avrc..., "Mark Jordan" <mark@c...> wrote:
>
> As you can find in the Mega128 datasheet, you CAN'T wake up
> from sleep using INT0/1 rising/falling edge.
> You have to use INT on LEVEL. So it will works.
>
> MArk Jordan > On 22 Apr 2004 at 14:29, inpactmicro wrote:
>
> > I cant get my ATMEGA 128 to power down and wait for an interrupt
on
> > rising edge of d0
> > any ideas where I am going wrong?
> > this is the code Im using
> >
> > //enable PORTD:0 (INT0) as interrupt input level High
> > EICRA = 0x03; //00000011 //rising edge on INT0
> > SREG = 1; //s-reg I flag
> > EIMSK = 0x01; //00000001 // enables external
interrupt
> > //EIFR = 0x01;
> >
> > //setup in power DOWN mode
> > //disable OCDN in fuses for max power saving
> > MCUCR = 0x28; //00101000 //SE = 1 //SM2..0 = 010
> > //SEI(); //enable global interrupt
> > asm("sei");
> >
> >
> > // sleep;
> > asm("sleep"); //sleep mode NOW! woken up by
rising edge
> > asm("nop");
> > asm("nop");
> >
> > //only wakes up when pin D) goes high
> > rest of program;
> >
> >
> >
> >
> >
> > Yahoo! Groups Links
> >
> >
> >
> >
> >





The 2024 Embedded Online Conference