Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

ATtin13 clock frequency mismatch

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Archive
View previous topic :: View next topic  
Author Message
Rahalph

Bascom Member



Joined: 01 Mar 2014
Posts: 36

PostPosted: Sat Nov 01, 2014 5:51 pm    Post subject: ATtin13 clock frequency mismatch Reply with quote

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

Code:

$crystal = 1200000
 


But know the 4.8MHz (CKDIV8=1 / SUT1..0 = 10 / CKSEL1..0 = 01).
The pin changes every 13!!! seconds with:

Code:

$crystal = 4800000
 


With 600kHz (CKDIV8=0 / SUT1..0 = 10 / CKSEL1..0 = 01) the same problem!

Code:

$crystal = 600000
 


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
View user's profile
weec

Bascom Member



Joined: 13 Oct 2013
Posts: 7

blank.gif
PostPosted: Sat Nov 01, 2014 8:26 pm    Post subject: Tiny 13a clockdiv Reply with quote

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
View user's profile
MWS

Bascom Member



Joined: 22 Aug 2009
Posts: 2262

blank.gif
PostPosted: Sun Nov 02, 2014 12:06 am    Post subject: Reply with quote

It's all described in the data sheet under "Calibration Bytes".
Back to top
View user's profile
Rahalph

Bascom Member



Joined: 01 Mar 2014
Posts: 36

PostPosted: Sun Nov 02, 2014 8:06 pm    Post subject: Reply with quote

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
View user's profile
MWS

Bascom Member



Joined: 22 Aug 2009
Posts: 2262

blank.gif
PostPosted: Sun Nov 02, 2014 9:11 pm    Post subject: Reply with quote

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
View user's profile
Rahalph

Bascom Member



Joined: 01 Mar 2014
Posts: 36

PostPosted: Sun Nov 02, 2014 10:59 pm    Post subject: Reply with quote

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 Smile

Thanks again
Ralph
Back to top
View user's profile
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Archive All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum