ATmega64 | how to control external clock source

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

I have two cristals, 1.8432 MHz external clock an 32kHz on TOSC. When i go into "SLEEP_MODE_EXT_STANDBY" current falls to about 0,50 mA and 0,48 mA is consumed by clock.

 

 

My question is - how to turn off clock during sleep and is it possible to start clock from atmega64 ?

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

michalnow wrote:
My question is - how to turn off clock during sleep and is it possible to start clock from atmega64 ?
Did you read the chapter on sleep and specifically the table showing you the various sleep modes available. The more intense form of sleeping involve stopping more and more of the clocks but (generally) they are more difficult to wake up as there are fewer reactivation interrupts.

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

clawson wrote:

michalnow wrote:
My question is - how to turn off clock during sleep and is it possible to start clock from atmega64 ?
Did you read the chapter on sleep and specifically the table showing you the various sleep modes available. The more intense form of sleeping involve stopping more and more of the clocks but (generally) they are more difficult to wake up as there are fewer reactivation interrupts.

 

I did. This clock is controlled with its enable pin. I need some possibility to put it to logical 0 to turn it off, and back to 1 to turn it on. Problem is - program will stop if i turn off clock before sleep, and will not continue before it comes back (As far as I know !).

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

Maybe whatever signal wakes up the AVR can also set the XTAL enable high...it could be wired or'd so that then the AVR can force it to stay high, even if the signal goes away.

 

you didn't mention exactly what wakes things up.  If it is timer2 & the 32K xtal, this might help

http://kineticsandelectronics.com/sleep.html

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

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

It is not possible to change clock source on a mega64.

You could switch off the external clock when you first go to sleep.

 

But you can never wake up !!!

 

Surely it is easier to use the internal 2MHz RC.

It can sleep and wake up.

It will give you "good enough" accuracy for UART comms and most peripherals.

Obviously Timers will not be as accurate as with a crystal.

Your 32kHz TOSC can give you accurate RTC functionality.   You can even use the TOSC to calibrate the 2MHz RC.

 

Modern MCUs can switch clock source at run time e.g. from RC to crystal

The mega64 (and traditional Mega AVRs) can only select clock source by fuses.

 

David.

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

david.prentice wrote:
The mega64 (and traditional Mega AVRs) can only select clock source by fuses.

I'd speculate from the OP that the purpose of this snipe hunt is to minimize power consumption, and thus the clock contortions.

 

IME/IMO, if this is a primary concern, then use an AVR model with better characteristics.  Indeed you can haul gravel with a pickup truck, but you will never do a good job of it.

 

Choosing a more modern AVR8 model, even if not a late generation that can change cl0ock sources, will draw less power in all modes.  In addition, the wake-on-pin-change allows a common wakeup trigger to be used, and the AVR draws next to nothing in powerdown 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.

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

program will stop if i turn off clock before sleep

As far as turning the osc off, you can use an RC to delay the turning off by a few ms...that's 1/2 of the issue. 

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

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

michalnow wrote:
I have two cristals, 1.8432 MHz external clock an 32kHz on TOSC. When i go into "SLEEP_MODE_EXT_STANDBY" current falls to about 0,50 mA and 0,48 mA is consumed by clock

 

Is that .5ma/.48ma  or is it 50ma/48ma?  Big difference

 

If the first, then its operating correctly.  .5ma, or 500microamps is nothing. 

 

50ma on the other hand is too high for sleep mode.

 

michalnow wrote:
My question is - how to turn off clock during sleep and is it possible to start clock from atmega64 ?

You are using an external oscillator with an enable pin.  Why?  And why would you want the AVR to turn off its clock?

 

As others have been guessing it looks like you want to operate on the 32khz crystal while in sleep and hen kick it into high gear when awake.  There are numerous threads on how fast a clock should be used for maximum battery life etc.

 

Before this thread turns into a long winding road of frustration can you explain your thinking on this dual crystal/oscillator setup?

 

JIm

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user