Yahoo Groups archive

AVR-Chat

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

Message

Re: [AVR-Chat] Sleep ATMega16

2009-04-29 by Jim Hatley

Probably need to enable internal pullup on receive pin or put on an external pullup to be sure receive pin is kept high.

Jim

  ----- Original Message ----- 
  From: Gmail 
  To: AVR-Chat@yahoogroups.com 
  Sent: Wednesday, April 29, 2009 9:23 AM
  Subject: [AVR-Chat] Sleep ATMega16





  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]

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.