attiny sleep wakeup time much longer than spec

Go To Last Post
9 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I've been testing interrupt latency on t13s and t85s, and the datasheet numbers are way off.  Table 6-5 (t13) & 6-7 (t85) both state 6 CK for start-up time from power down.  So according to s. 9.2.1, INT0 held low for >6 clocks should be enough to wake up and run the ISR.  I've found it takes about 32 clocks to cause the ISR to run, both for INT0 and PCINT.  2 clocks is enough to wake up from sleep and continue execution from the next instruction after sleep without running the ISR.

 

Has anyone else noticed this?

 

I checked for a simple mistakes like leaving the div8 fuse set, but it is not.  I even did a test with PWM output to make sure my t13 was running >9Mhz.

To generate the wake-up pulses I used a USB-TTL UART, and used my Rigol scope to make sure the pulses have the correct timing.

 

In active mode interrupts work exactly as specified in the datasheet; INT0 latency is 4 clocks, and PCINT is 6.  The PCINT synchronizer shown in figure 9-1 adds 2 clocks of latency.

I have no special talents.  I am only passionately curious. - Albert Einstein

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Program the CKOUT fuse and observe the actual clock pulses during wakeup.  I expect that the first few cycles will not show accurate timing.  I've never checked it myself, but it would be interesting to see how long those 6 clock cycles are.  This may account for some of the observed 32-clocks at nominal frequency, but I expect not all of it.  Perhaps none!

"Experience is what enables you to recognise a mistake the second time you make it."

"Good judgement comes from experience.  Experience comes from bad judgement."

"Wisdom is always wont to arrive late, and to be a little approximate on first possession."

"When you hear hoofbeats, think horses, not unicorns."

"Fast.  Cheap.  Good.  Pick two."

"We see a lot of arses on handlebars around here." - [J Ekdahl]

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I glossed over that 6CK when I read the datasheet the first time, probably because it was plenty fast enough for my projects.

 

The Datasheet states:

Any clock source needs a sufficient Vcc to start oscillating and a minimum number of oscillating cycles before it
can be considered stable.

 

I guess the 1st few cycles are considered unstable and could be much slower than expected.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

But isn't OP saying that with the same clock source, it somehow takes longer when there is an interrupt involved?  I thought there always needed to be an interrupt involved for the wake-up source?

ralphd wrote:
it takes about 32 clocks to cause the ISR to run, both for INT0 and PCINT.  2 clocks is enough to wake up from sleep and continue execution from the next instruction after sleep without running the ISR.

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.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

theusch wrote:

But isn't OP saying that with the same clock source, it somehow takes longer when there is an interrupt involved?  I thought there always needed to be an interrupt involved for the wake-up source?

ralphd wrote:
it takes about 32 clocks to cause the ISR to run, both for INT0 and PCINT.  2 clocks is enough to wake up from sleep and continue execution from the next instruction after sleep without running the ISR.


No I think he's saying the interrupt ISR should be running in both cases but it's not. Almost like the isr has a glitch filter when sleep that's not there when not sleep.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

joeymorin wrote:

Program the CKOUT fuse and observe the actual clock pulses during wakeup.  I expect that the first few cycles will not show accurate timing.  I've never checked it myself, but it would be interesting to see how long those 6 clock cycles are.  This may account for some of the observed 32-clocks at nominal frequency, but I expect not all of it.  Perhaps none!

 

While that won't work for the t13 (no CKOUT fuse), it's an interesting idea for the t85.  It got me thinking how the 6 clock start-up time can only count after the RC oscillator has itself started up.  The time between application of power to the circuit and the first oscillation is nowhere to be found in the datasheets.  I did some research, and for low-power RC oscillators, 2-4us seems to be typical.  For example the STM32 HSI16 oscillator startup time is 3.7us.

https://www.st.com/resource/en/a...

 

My ~32 clock startup time measurements works out to 3.5us for the oscillator to start + 6 clocks.  I suspect if I tried with 3V3 instead of 5V power the time would be slightly longer.

I consider the issue "solved" in the sense that I'm confident about what is happening, but I also consider it a failure on Atmel's part for not providing full specs on the internal RC oscillator.

 

I have no special talents.  I am only passionately curious. - Albert Einstein

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

theusch wrote:

But isn't OP saying that with the same clock source, it somehow takes longer when there is an interrupt involved?  I thought there always needed to be an interrupt involved for the wake-up source?

ralphd wrote:
it takes about 32 clocks to cause the ISR to run, both for INT0 and PCINT.  2 clocks is enough to wake up from sleep and continue execution from the next instruction after sleep without running the ISR.

 

2 clocks is enough to wake up the part when the interrupt is enabled, but it needs to be held longer in order to cause the interrupt to run.  This is documented at s 9.2.1:

"Note that if a level triggered interrupt is used for wake-up from Power-down, the required level must be held long enough for the MCU to complete the wake-up to trigger the level interrupt. If the level disappears before the end of the Start-up Time, the MCU will still wake up, but no interrupt will be generated."

 

I have no special talents.  I am only passionately curious. - Albert Einstein

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

So in the end its not the "sleep wakeup" time that is longer than expected but its the sleep to ISR time.

Good thread.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

dnoyeB wrote:

So in the end its not the "sleep wakeup" time that is longer than expected but its the sleep to ISR time.

Good thread.

Actually the wakeup time from power-down sleep is about 3.5us longer, whether the ISR runs or not.  Wakeup time from idle is as per the datasheet.

 

I have no special talents.  I am only passionately curious. - Albert Einstein