[atmega8] Can't wake up from sleep mode
- From: ilovecpp@xxxxxxxxx
- Date: 21 Jul 2005 07:25:22 -0700
Hi.
I am working with Atmega8 and I installed Timer/Count2 interrupt
service routine. Following the Atmega8 manual, it is possilble that
Timer/Count2 ISR can wake up sleep mode(power save)if AS2 is set in
ASSR.
But, My code never wake up.
#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/signal.h>
#include <stdio.h>
void Uart_Put_Char(unsigned char data)
{
while ( !( UCSRA & (1<<UDRE)) );
UDR = data;
}
void Hardware_Init(void)
{
// Set Sleep Mode
MCUCR = 0xb0;
UBRRL = 16;
UCSRA = 0x00;
UCSRB = 0x18;
//Timer Interrupt Setting.
// AS2 Set in ASSR because wake up from power save mode
ASSR |= 0x08;
// Clock(16Mhz) / 256
TCCR2 = 0x06;
// X / (249 + 1)
// it means that Timer ISR called every 250hz.
OCR2 = 249;
// Timer/Counter2 Output Compare Match Interrupt Enable
TIMSK = 0x80;
// Timer/Counter Register Reset.
TCNT2 = 0x00;
__asm volatile("cli");
}
SIGNAL(SIG_OUTPUT_COMPARE2)
{
Uart_Put_Char('C');
}
void SaveMode(void)
{
while ( !( UCSRA & (1<<TXC)) );
__asm volatile ("sleep");
}
void main(void)
{
Hardware_Init();
__asm volatile("sei");
while(1)
{
Uart_Put_Char('A');
SaveMode();
Uart_Put_Char('B');
}
}
This code's result is just "A" and the worst thing is that it never
print "C"
Could you tell me why ?
Thank you.
.
- Prev by Date: Re: Editor?
- Next by Date: Re: Outlook 2003 does not find Notes by Cyrillic text in them
- Previous by thread: Re: Editor?
- Next by thread: re:Recommendations for ARM compilers
- Index(es):
Relevant Pages
|