I am powering up my first hardware using s08JM60.
I am very unsure about the operation of the Clock Generator (MCG)...
Using the cpu internal ~32.7khz oscillator I can trim the bus frequency by altering values in MCGTRM
[using the code below, the default TRIM value $80 gives a bus freq that gives me 115K baud out the serial comms SCI unit]
Using an external 32.768 khz oscillator, the bus freq. is ~10% too slow (for 115K baud generation) and the MCGTRM value does not alter the bus freq.
Is this correct? How can I trim to get 115K baud?
internal osc startup code:
; MCGC2: BDIV=1,RANGE=0,HGO=0,LP=0,EREFS=0,ERCLKEN=0,EREFSTEN=0
MOV #$40,MCGC2 ; Set MCGC2 register
; MCGC1: CLKS=0,RDIV=0,IREFS=1,IRCLKEN=1,IREFSTEN=0
MOV #$06,MCGC1 ; Set MCGC1 register
; MCGC3: LOLIE=0,PLLS=0,CME=0,VDIV=1
MOV #$01,MCGC3 ; Set MCGC3 register
while_Cpu0: ; Wait until FLL is locked
BRCLR 6,MCGSC,while_Cpu0
external osc startup code is as above but does
MOV #$06,MCGC1
Solved! Go to Solution.
Yes, that is correct!
You generally have a finer adjustment than the old ones though.
But it still gets "coarse" as you get up into these higher baudrates.
Hi Don,
I did not check through your clock setup but it seems you are assuming that the trim register will affect the frequency when an external oscillator or crystal is used. This is NOT the case.
The trim register works by switching in additional capacitors into the INTERNAL oscillator and so ONLY affect the frequency of the internal oscillator.
OK, so to get a standard baud rate (such as 115K baud)
I must have a suitable external osc freq. which divides down/up to get
the correct bus freq., as is the requirement in older type uP's
Yes, that is correct!
You generally have a finer adjustment than the old ones though.
But it still gets "coarse" as you get up into these higher baudrates.