problem waking up ATxMega384

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

Hi all:

I am facing an annoging problem,

I am working on a project where I need to get the ATxMega in SLEEP_SMODE_PSAVE_gc mode and wake up every 5 minutes using the RTC.
I configured the RTC so that you wake up every second, and increase a counter until the number of seconds (300) is satisfied, but for some reason, I don't understand, 1% of the times the ATxMego 
does not leave that cycle so I assume it doesn't wake up.

Could you Pls. help me on that, Has anyone faced a similar problem?

Any suggestions to detect where the problem occurs?

 

Thanks in advance

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

Your counter is a multibyte value (ie. >255), so takes at least two reads to get its value, which can be interrupted and changed mid read.

Check your toolchain manual for how to read multibyte values atomically in your main() function.

Jim

 

 

(Possum Lodge oath) Quando omni flunkus, moritati.

"I thought growing old would take longer"

 

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

Thaks you Jim:

Just for test I decrease the time to 60 secs, and it works fine.

 

Thanks again.