9S08QG8 internal clock accuracy

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

9S08QG8 internal clock accuracy

2,211 Views
stevec
Contributor III
I'm a new user to this chip and want to use it's serial USART for communicating with an external device. I wish to use the internal oscillator as a clock source so that I can use the external clock pins for I/O. I have found that the stability of the internal clock is 2% which should be adequate for serial comms at 19200 baud. What steps do I have to go through to ensure that the internal clock is set correctly. I must admit to being confused by the trim thing. I have always used an external crystal for previous designs but need a couple of extra pins. Does the default internal clock get set to 32kHz? or is this frequency dependant on the trim register?
Labels (1)
0 Kudos
4 Replies

327 Views
stevec
Contributor III
Thanks Peg,
Does this mean that the trim value will need setting for every device programmed?
0 Kudos

327 Views
Encoder
Contributor I
Hi Stevec.
 
With proper settings, CodeWarrior will detect correct clock trim variable for the actual cpu and will write it into a default location in flash when you'll upload your program in flash.
 
Just copy this variable in the right register at the beginning of your code and the clock will be precisely set. On 9S08AW60 I achieve nearly 0.5% precision at ambient temperature this way. For this uC the first 2 line of ASM code in my program are:
 

lda OSCTRMDEFAULT  ; load CW detected trimmer variable from default location

sta OSCTRM                ; Preset oscillator trim factor, writing the clock trimmer register

 
I think that this may be the same for 9S08QG8 (see your default 9S08QG8.inc and the data sheet for the variable names and locations)
 
Bye,
Encoder
 
0 Kudos

327 Views
stevec
Contributor III
That's good news. I should have my demo kit tomorrow so will get to grips with it over the next few days. An active forum certainly has to be a big factor in choice of processor nowadays. These things didn't exist when I started with microprocessors nearly 30 years ago. Thanks all
0 Kudos

327 Views
peg
Senior Contributor IV
Hi stevec,
 
The internal clock is nominally 32.7kHz. But from device to device it varies over quite a wide range. The 9 binary weighted trim bits are there to fiddle this frequency so it is as close as possible to the intended frequency. This is perfectly adequate for baudrate generation even without the fine (9th) bit. Programmer software either from P&E or within Codewarrior etc will usually tell you the necessary trim value which you programme into $FFAE:FFAF then copy down to $003B:003A on initialisation.
 
0 Kudos