Re: [AVR-Chat] Sleep ATMega16
2009-04-29 by STEVEN HOLDER
Try reintialising the uart when you wake up, turn it off when you go to sleep. Set the pins as input high impedance in sleep mode. It is a good idea to have a sleep routine run just before you go to sleep, then a wake routine, so that any values can be set/ cleared consistantly. Regards --- On Wed, 29/4/09, Gmail <moatazhussein@gmail.com> wrote:
Show quoted textHide quoted text
From: Gmail <moatazhussein@gmail.com> Subject: Re: [AVR-Chat] Sleep ATMega16 To: AVR-Chat@yahoogroups.com Date: Wednesday, 29 April, 2009, 8:55 PM What i did is that when it wakes, i inserted a delay of 200 ms then started to get data from AD (SPI) and send it (UART), nothing happened; same results. Moataz Hussein ----- Original Message ----- From: wagnerj@proaxis. com To: AVR-Chat@yahoogroup s.com Sent: Wednesday, April 29, 2009 9:53 PM Subject: Re: [AVR-Chat] Sleep ATMega16 Be aware that the processor takes time to wake up. Also, be careful NOT to sleep until all of the bytes have been sent. This means staying awake until the very last stop bit has left the UART. In other words, you cannot just put a byte into the UDR, then sleep. You need to wait until the byte is actually finished. Jim Wagner Oregon Research Electronics > I am working on on a system to record temperature on a flash memory at a > programmed rate. > As there is nothing to be done between samples (1 Sec- 15 Mins) and it is > battery powered I want it to sleep between samples. > > I am using Mega 16, A/D MCP3550 on Spi, running on 3.6864 Mhz Crystal. > > The first step I did was to read from A/d and send it by uart to check > readings, it was ok. > > When I started to introduce sleep, I got zeros received by uart! even the > number of bytes sent. > So I conclude that the problem is when waking after the sleep, is there > any thing that I missed or settings to be done so that I get it work as I > want it? > > Code Bellow. > > Thanks, > Moataz Hussein > > ;/////////// ////// > ; Timer2 overflow > ;/////////// ////// > > Timer2_Ovf: > > clr temp ; Disable sleep > out mcucr,temp > > dec temp1 ; Loops counter > brne hh > > ldi temp1, 225 ; Reset Counter value to 225 when done > > hh: > ldi Temp,LOW(Sec1) ; After interupt completed go back to Sec1 > push Temp > ldi Temp,HIGH(Sec1) > push Temp > reti > > ;/////////// ////// > ; Main > ;/////////// ////// > > Main_sample: > > rcall sample ; Read from A/d And send by UART > > sei > ldi temp, 0b01000000 > out timsk, temp > > Ldi Temp, 0b00000100 ; Prescaller 64 > out tccr2, temp > ldi temp1, 225 ; No of loops to get 1 Sec > > > > TMRLOOP: > > ldi temp,0b01010000 ; Enable sleep, mode > ; out mcucr,temp > sleep > Rjmp TMRloop > > Sec1: > Ldi temp, 225 > cpse temp, temp1 > rjmp tmrloop > > Rjmp Main_sample > > [Non-text portions of this message have been removed] > > [Non-text portions of this message have been removed] [Non-text portions of this message have been removed]