Digital clock signal to TOSC1

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

I'm about to connect an external 32kHz digital clock signal (not a 32kHz crystal) to TOSC1 for using Timer2 in Power Down mode. The data sheet for ATmega16 states this about the T/C2 async:

Quote:
The Oscillator is optimized for use with a 32.768 kHz watch crystal. Applying an external
clock to the TOSC1 pin may result in incorrect Timer/Counter2 operation. The CPU main
clock frequency must be more than four times the Oscillator frequency.

Is that quote saying that connecting anything else than a crystal may result in incorrect operation, or is it stating that connecting anything else than 32kHz (crystal or other) may result in incorrect operation, or is it anything else than a just a 32 kHz crystal that may cause incorrect operation?
The last two sentences is indicating that it is the frequency that is the focus.

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

It says that applying an external clock may result in incorrect Timer/Counter2 operation.
You say you will be applying an external clock. So you can expect that your action may result in incorrect Timer/Counter2 operation. The TOSC1 pin is meant to be used with an external crystal (specifically a 32.768kHz watch crystal) to provide an oscillator circuit, it is not meant to be driven by an external clock.

Smiley

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

Some of the newer AVRs like the ATmega164P are able to use an external clock input on the TOSC1 pin.

mega164P data sheet wrote:
14.11.6 ASSR – Asynchronous Status Register
Bit 6 – EXCLK: Enable External Clock Input
When EXCLK is written to one, and asynchronous clock is selected, the external clock input buffer is enabled and an external clock can be input on Timer Oscillator 1 (TOSC1) pin instead of a 32 kHz crystal. Writing to EXCLK should be done before asynchronous operation is selected. Note that the crystal Oscillator will only run when this bit is zero.
You just have the wrong AVR for the external clock connection you want to use.

AVR505: Migration between ATmega16/32 and ATmega164P/324P/644(P)
http://www.atmel.com/dyn/resourc...

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

Unfortunately the 164P is a lot more expensive than the version were currently using, they are even whining about the extra cost of adding a 5 cent crystal. Since the digital clock signal is already there it would be very good if it could be used.
Does anyone know what the "incorrect behavior" is? Will it randomly occur on every device, or will it only occur on some devices?

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

The exact incorrect behavior characterization really doesn't matter. Although since you are driving a crystal oscillator feedback circuit I would expect instability. Still, no matter what you do you will never achieve reliability and if anything goes wrong in a production unit or units, where you ignored the manufactures data sheet, guess who's fault that is :wink:

The only thing special about the ATmega16 timer/counter2 is its designed to be clocked asynchronously with respect to the AVR internal clock and only by a 32 khz crystal. The synchronization is handled somewhere between the timer/counter2 internal registers (clocked by the watch crystal) and the internal AVR bus (clocked by the AVR clock) interface.

You may use the external clock input T0 pin for timer/counter0 or T1 pin for timer/counter1. The difference is the T0 and T1 input pins are synchronized to the AVR clock at these input pins, not at the internal register interface. Other than the watch crystal clock source, there isn't anything else special in timer/counter2 that supports real time clock operation. If you don't need or have a watch crystal, you don't need timer/counter2.

The maximum recommended T0 or T1 frequency at a 50% duty cycle is 2.5 times slower than the AVR clock frequency. Since you are not using the 32 khz watch crystal, why not change timer/counters and use T0 or use T1 instead?

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

Quote:

there isn't anything else special in timer/counter2 that supports real time clock operation.

Well, there are considerations with Timer2 in many AVR models for low-power operation that are special--"clkASY". However, if doing a low-power app why would one be using a [relatively] power-hungry model like the Mega16 when the Mega164 is readily available, is less expensive, and has more power-saving features?

Quote:

...using Timer2 in Power Down mode.

Speaking of low-power modes and clkASY, I don't know of any AVR model that will run "Timer2 in Power Down mode".

Lee

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

Mike B wrote:
guess who's fault that is :wink:
Well I just provide my employer with information, the decision is theirs to make so my behind is covered =) That's why I need as much information as possible, "may result in incorrect behavior" is equal to "might work good enough"... I take it that no one has tried, so I'll be first tomorrow then :D Hopefully it fails miserably and we will have no other option than adding the extra crystal.

Lee: Of course I meant Power-Save mode :roll: Your saying that the 164P(A?) is less expensive? I was told that they were told that the 164P were almost twice as expensive as the 16A (or was it 16L) we're currently using.

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

At mouser a mega16A is $4.01 per 100, a mega164p is $4.12 per 100, a mega16L is $4.86 per 100.

Regards,
Steve A.

The Board helps those that help themselves.

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

I tried this and it works with just the unmodified digital clock signal. I also contacted Atmel and this is the response I got:

Quote:
Normal input on TOSC1 when configured as Timer Oscillator is 1 Vp-p centred
around 0,7 V. Using a 0 - Vdd square results in a poor duty cycle and high
current consumption.

If it is desired to use a square input, it is recommended to use a R and a
C in series with TOSC1.
Square in -> -R-> -C-> TOSC1, where R ~1 Mohm and C ~7 pF.
The idea is to reduce the amplitude and have it centred on the amplifiers
operating point.
Use an oscilloscope to verify the waveform.

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

So, COLA is after low power, wants to sleep, won't use a less expensive model; the less expensive model has greatly enhanced low-power features; and is struggling to use a feature in a manner that causes higher power consumption.

Do I have the summary correct? This is like struggling to get higher fuel efficiency for commuting out of a dump truck.

Lee

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

BTW,

Digikey has the following:

Mega16, Mega16L 3.81 Qty 100
Mega164P 3.18 Qty 100

For 40 Pin DIP

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

I have tested this some more now, measured the current consumptions in Power Down and in Power Save with different combinations on the TOSC1/2.

Power Down mode
0,275 µA - MCU only
0,274 µA - MCU + 32kHz clock w. suggested fix (TOSC2 n/c)
0,273 µA - MCU + 32kHz crystal

Power Save mode
7,076 µA - MCU only
7,963 µA - MCU + 32kHz clock w. suggested fix (TOSC2 n/c)
7,924 µA - MCU + 32kHz crystal

So there is no significant increase in power consumption when using the clock signal instead of a crystal.
These numbers are with the ATmega16L, so when we change to 164PA this will be even better. :)

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

The mega164PA has the ASSR register EXCLK setting. You can run this AVR in a factory supported external clock mode without worrying about design or production batch changes/variables that you expose yourself to by ignoring the factory recommendations. Besides, the mega164PA has lots of low power improvements the mega16 never even dreamed of.

BTW, since you are using an analog mega16L crystal oscillator input with a digital signal instead, did you remember to characterize your tests at all temperatures, reasonable Vcc regulator variations and for possible min/max variations in the digital drive signal levels? Any combination of these factors could possibly nullify your test results or even result in failure at combined logic threshold or Vcc extremes.

You did a nice job on your power consumption tests, but they are only valid under a very narrow set of conditions that you ran your test under. Manufactures run extensive characterizations before they publish what the chip can and cannot do, which allows end users like us to rely on its operation as published or get support from the factory. On the other hand a hobbyist has no reason to really care about any of this, they simply use whatever they can get to work.

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

COLA wrote:
Unfortunately the 164P is a lot more expensive than the version were currently using,
´
Where do you buy your AVRs?
At the all of the 3 different AVR distributors I checked, ATmega164P/PV is cheaper than both ATmega16L and ATmega16A.
Do you buy some new old stock non-RoHS ATmega16L at discount price?

The new ATmega164PA that is going to replace both ATmega164P and ATmega164PV is most likely going to be even cheaper than 164P. Other 'A' models are cheaper than the AVRs they have replaced, for eaxample ATmega16A is cheaper than ATmega16/16L.

1 unit prices:

Arrow North America:
ATmega16L: $5.09 - $5.18
ATmega164P/PV: $3.80

DigiKey:
ATmega16L: $6.45 - $6.56
ATmega164P/PV: $4.82

Mouser:
ATmega16L: $7.00 - $7.12
ATmega16A: $5.84
ATmega164P/PV: $5.23

ATmega16A is not in stock at Arrow and DigeKey, but it is at Mouser.
The new ATmega164PA is not available at any distiubutors yet. But Atmel probably claims "available now" if I know them right.

Besides when you use ATmega164P/PV/PA you can also save the watch crystal.