Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Message

Re: [AVR-Chat] Sleep ATMega16

2009-04-29 by Philippe Habib

I don't know what the case is with your part, but some parts have a  
sleep mode that lets the ADC run and the int can trigger an ADC read  
to happen.

I'd read up on the various sleep mode and see if one is a good fit for  
what you're trying to do.


On Apr 29, 2009, at 11:53 AM, wagnerj@proaxis.com wrote:

> 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]
>>
>>
>
>
>
>
> ------------------------------------
>
> Yahoo! Groups Links
>
>
>

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.