Forum Menu




 


Log in Problems?
New User? Sign Up!
AVR Freaks Forum Index

Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
Chilligan
PostPosted: Mar 28, 2011 - 02:20 PM
Newbie


Joined: May 05, 2008
Posts: 3


Hi,

I've been having trouble with exiting deep sleep mode on the atmega128rfa1 (on the atmega128rfa1-ek1 board) with the MAC symbol counter.
The datasheet states that the Symbol counter has "Low-power, deep-sleep mode operation and system wake up with all symbol counter interrupt events".
It also says that "If the transceiver goes from active mode into sleep mode, the symbol counter clock source is switched to the RTC clock automatically".

All of this has led me to believe that I can wake-up the controller from deep sleep mode with the symbol counter running on the RTC clock.

I have had successful wake-ups in the following scenarios:

* 16MHz/32.768kHz clock, Transceiver SLEEP (not actual wake-up but transceiver was sleeping)
* 16Mhz clock, Controller in power-save mode.
* 16Mhz clock, Controller in power-down mode.

What is especially interesting is that I cannot exit power-save mode with the symbol counter working on the TOSC 32.768kHz clock even though Timer2 works in that scenario.

I should mention that I can exit any sleep state with a switch (external interrupt).

Does anyone how to properly do it? I've looked on the Bitcloud source code, they use Timer2 with power-save.

LE:
Well it seems I was entering wrong mode (typo)

Code:

SMCR = _BV(SM1)  | _BV(SM0) |  _BV(SE);


is the correct command for powersave, not SM1/SM2 as was in my code. I can exit deepsleep mode now.

In this case, do you know what are the differences between deepsleep/powersave and deepsleep/powerdown with respect to consumption? I suppose I cannot exit deepsleep/powerdown with the symbol counter running on RTC clock, since it seems to be turned off in powerdown mode.


Thanks,

Andrei

Code:

#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/wdt.h>
#define F_CPU 16000000UL
#include <util/delay.h>


void res();
ISR(INT5_vect)
{
   res();
}

ISR(SCNT_CMP1_vect)
{
   PORTE &= ~_BV(PE2); // green LED
}
void res()
{
   wdt_enable(WDTO_500MS);
   cli();
   while(1);
}
int main()
{
   MCUSR = 0;
   wdt_disable();
   DDRE = 0xff;
   PORTE = 0xff;


   PORTE &= ~_BV(PE4);// red LED
   _delay_ms(500);
   PORTE |= _BV(PE4);

   // enable falling-edge interrupt  on INT5 (switch SW1 on the board)
   PORTE |= _BV(PE5);
   DDRE &= ~_BV(PE5); //input with pull-up
   //EICRB |= _BV(ISC51);
   EIMSK |= _BV(INT5);


   while (TRX_STATUS_struct.trx_status != TRX_OFF);
   
   ASSR |= _BV(AS2); // enable asynchronous mode, with external oscillator (32.768kHz in our case)

   SCOCR1HH = 0x00; // count to 2^17, should give a period of 4s
   SCOCR1HL = 0x04;
   SCOCR1LH = 0x00;
   SCOCR1LL = 0x00;
   SCCR0 = _BV(SCEN) | _BV(SCCKSEL);    // enable symbol counter, with TOSC1/2 clock (32.768kHz)
   SCCNTHH = 0x00;
   SCCNTHL = 0x00;
   SCCNTLH = 0x00;
   SCCNTLL = 0x00;


   while (SCSR & _BV(SCBSY));
   SCIRQM |= _BV(IRQMCP1);          // enable compare match 1 IRQ

   sei();

   TRXPR |= _BV(SLPTR);

   SMCR = _BV(SM1)  | _BV(SM0) |  _BV(SE);
   asm("sleep");
   SMCR = 0;

   while(1)
   {
      PORTE ^= _BV(PE3); // blink yellow led
      _delay_ms(100);
   };
}
 
 View user's profile Send private message  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT + 1 Hour
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2006 The PNphpBB Group
Credits