View previous topic :: View next topic |
Author |
Message |
Rahalph
Joined: 01 Mar 2014 Posts: 36
|
Posted: Sat Nov 01, 2014 5:51 pm Post subject: ATtin13 clock frequency mismatch |
|
|
Hi all,
I have a strange phenomenon here. I have multiple Tiny13A running at 5V. Atmel's datasheet says the controller has two frequencies, 9.6MHz and 4.8MHz.
9.6MHz seems to be correct (CKDIV8=1 / SUT1..0 = 10 / CKSEL1..0 = 10).
Following code changes the pin every 10 seconds:
Code: |
$regfile = "ATtiny13.dat"
$crystal = 9600000
Config PORTB.1 = Output
Do
Wait 10
Toggle PORTB.1
Loop
|
1.2MHz (9.6MHz divided by 8) seems to be correct, too (CKDIV8=0 / SUT1..0 = 10 / CKSEL1..0 = 10).
Same code as above, but
But know the 4.8MHz (CKDIV8=1 / SUT1..0 = 10 / CKSEL1..0 = 01).
The pin changes every 13!!! seconds with:
With 600kHz (CKDIV8=0 / SUT1..0 = 10 / CKSEL1..0 = 01) the same problem!
I get better results when I configure $crystal = 3600000 respectively 450000.
I checked that with a Timer, too. Seems to me the Tiny has 3.6MHz, not 4.8!
More than 10 new Tiny's faulty? A dozen typos in the datasheet?
Has anyone ever had this problem?
Thanks
Ralph
(BASCOM-AVR version : 2.0.7.7 ) |
|
Back to top |
|
|
weec
Joined: 13 Oct 2013 Posts: 7
|
Posted: Sat Nov 01, 2014 8:26 pm Post subject: Tiny 13a clockdiv |
|
|
Hello Rahalph,
1:
make the 'Lock and Fuse Bits' open in Bascom "Program - Send to chip - manual program" the programmer must conect it
have a look on the picture settings.JPG: Fusebit E 1: Divide clock by 8, OFF
Fusebit DCBA: 1010:Int. RC Osc 9.6 MHz
2:
try the Bascom-program Test_Tiny13a.bas
it works fine. The timing ist correct with my Tiny13a.
In BASCOM, you can change the Clockspeed with config Clockdiv = 1 or 2 or 4 or.............256.
Try the Test_Tiny13a.bas.
Have a good day
werner
sorry for my bad english. |
|
Back to top |
|
|
MWS
Joined: 22 Aug 2009 Posts: 2262
|
Posted: Sun Nov 02, 2014 12:06 am Post subject: |
|
|
It's all described in the data sheet under "Calibration Bytes". |
|
Back to top |
|
|
Rahalph
Joined: 01 Mar 2014 Posts: 36
|
Posted: Sun Nov 02, 2014 8:06 pm Post subject: |
|
|
Thanks for your answers guys.
Werner, I know about the CLOCKDIV parameter. It is a workaround but does not explain why the frequency is wrong when setting the fuse bit to 4.8MHz (what means nothing more than an interal divider by two).
MWS, I know that the Tiny13 has two built in calibration bytes (one for the 9.6MHz and one for the 4.8MHz). But I've never seen before that the factory calibration is that imprecise. I was expecting something between 4.6 and 5MHz worst case. But 3.6MHz, a difference of 25% ? A bit much. And for more than one or two chips?
Can the factory default really be that wrong? |
|
Back to top |
|
|
MWS
Joined: 22 Aug 2009 Posts: 2262
|
Posted: Sun Nov 02, 2014 9:11 pm Post subject: |
|
|
Rahalph wrote: | Can the factory default really be that wrong? |
The factory default is good for 9.6MHz and according your tests, it is sufficiently exact within operating conditions.
But the default value for OSCCAL is not valid for 4.8MHz, the datasheets says that and how to account for.
Whether these 25% don't meet your expectations, you may discuss with Atmel, but also Atmel will tell you to read the fine manual.
So I'm wondering, why you guess even further, instead of fixing it.
You have these chips sitting in front of you, why don't you simply read the second calibration byte and write it into OSCCAL? It will take you two minutes and then you'd be able to post your results here. |
|
Back to top |
|
|
Rahalph
Joined: 01 Mar 2014 Posts: 36
|
Posted: Sun Nov 02, 2014 10:59 pm Post subject: |
|
|
Hi MWS,
I was guessing further because I couldn't find the problem. But your last post gave me the right hint, thanks!
I missed that sentence of the datasheet: "The hardware always loads the 9.6 MHz calibraiton data during reset"
It took a little more than two minutes, but when I read the second calibration byte out of the signature and manually write it into OSCCAL, the frequency 4.8MHz is correct (or at least within the expected boundaries).
There we go! Let's me rest easier
Thanks again
Ralph |
|
Back to top |
|
|
|