## [ATmega128RFA1] What's the symbol counter clock?

4 posts / 0 new
Author
Message

I want to put the mcu to deep-sleep and then wake it up some time later.
The datasheet says the clock source can be the RTC crystal, which is 32.768kHz, so I would expect that the symbol counter counted at that speed. This would mean I'd have 2 seconds every 2^16bits in the counter, but instead I'm getting ~1s.

According to this post, every 2^16bits in symbol counter is one second, now why?
I thought the symbol counter would count at the RTC frequency, doesn't it?

On section 10.2 on the datasheet, it says

Quote:
Note: The AVR system clock has to be at least 4 times the symbol counter clock
frequency. The symbol counter clock frequency is usually 62.5kHz, which would require
a minimum of 250kHz AVR system clock frequency

That 'usually' doesn't satisfy me, since that means that sometimes the clock isn't running at that speed, so, how could I control for how long the mcu goes to sleep if I don't know the frequency of the counter.

Anybody knows?

My code:

```
#include
#include
#include
#include

uint8_t temp;

ISR(SCNT_CMP1_vect)
{
}

int main(void)
{
temp = MCUSR;
MCUSR = 0;
wdt_disable();

serial_init();  //Debug only

SCCR0 = (1<<SCEN) | (1<<SCCKSEL);
TRXPR |= (1<<SLPTR);

#define SLEEP_IDLE          0x00
#define SLEEP_POWER_DOWN    0x02
#define SLEEP_POWER_SAVE    0x03

ASSR |= (1<<AS2);

SCOCR1HH = 0x00;
SCOCR1HL = 0x28;   //this gives around 42s
SCOCR1LH = 0x00;
SCOCR1LL = 0x00;

SCCNTHH = 0;
SCCNTHL = 0;
SCCNTLH = 0;
SCCNTLL = 0;
while(SCSR & (1<<SCBSY));
SCIRQM |= (1<<IRQMCP1);

printf("\n\tEntra a Deep-Sleep\n");

sei();
SMCR_struct.sm = SLEEP_POWER_SAVE;
SMCR_struct.se = 1;
asm("sleep");

SMCR_struct.sm = SLEEP_IDLE;
SMCR_struct.se = 0;
temp = SCCNTLL;

while(1)
{

}
}```

I think the counter is still running at 62.5kHz, as power-save and idle are not "deep sleep"?

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

theusch wrote:
I think the counter is still running at 62.5kHz, as power-save and idle are not "deep sleep"?

From the datasheet
Quote:
When the microcontroller goes into Power-down or Power-save modes while the
transceiver is in SLEEP state the device enters the Deep-Sleep mode

So it should be in deep-sleep, doesn't it?

The line

`TRXPR |= (1<<SLPTR);`

send the transceiver to sleep.