Trim value

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

Trim value

4,875 Views
FordFairlaneBen
Contributor I
Hi:
I´m working with a MC9S08AW60 and I need a very accurate clock oscillator frequency. I have read that is possible adjust it with and option that appears in Processor Expert called "Trim Value Adress". But here only appears the address in which strore the value. My question is: what value have I to set to set the internal clock to 8Mhz with a very accuracy and where?
Thank you very much.
Best regards
Labels (1)
0 Kudos
9 Replies

1,189 Views
FordFairlaneBen
Contributor I
hi thisobj:
 Thank you very much. Your way to trim the MCU works but I can get the values I want. Nevertheless I get another value for ICGTMR different from 0xFF which I got everytime. 
The values that you set for
 
WRITE_BYTE_AND_SYNC=08/00000048/  
WRITE_BYTE_AND_SYNC=00/00000049/ 
HCS08_TRIM=004E/FFBE/003d0900/
 
are fixed or they vary with they frequency we want to calibrate. If it´s the last case, what is the formula to get the correct value?
Thank you very much.
Best regards
0 Kudos

1,189 Views
bigmac
Specialist III
Hello,
 
If you need "a very accurate clock oscillator frequency", perhaps you need to use an external crystal rather than the internal oscillator.  After trimming, the frequency stability for the latter is specified at plus/minus 2 percent over voltage and temperature range.  This is not what I would consider "very accurate".  What timing accuracy do you require?
 
Regards,
Mac
 
0 Kudos

1,189 Views
FordFairlaneBen
Contributor I
hi Big Mac:
The accurate I need is +/- 7% of the nominal frequency which is 7,7Mhz. The problem I have is that in the address 0xFFBE I always get the same value 0xFF. And I have checked the check box "Calculate Trim and Program the Non-Volatile Trim Register"  in P&E/ Multilink Cyclone Pro -> Advanced Options and is activated.
Have I omitted any step?
Thanks.
Regards.
0 Kudos

1,189 Views
thisobj
Contributor III
>hi thisobj:
>Thank you very much. Your way to trim the MCU works but I can get the values I want. Nevertheless >I get another value for ICGTMR different from 0xFF which I got everytime. 
>The values that you set for
 
>WRITE_BYTE_AND_SYNC=08/00000048/  
>WRITE_BYTE_AND_SYNC=00/00000049/ 
>HCS08_TRIM=004E/FFBE/003d0900/
 
>are fixed or they vary with they frequency we want to calibrate. If it´s the last case, what is the formula to >get the correct value?
>Thank you very much.
>Best regards
 
The value I chose, "3d0900", is for a 4MHz bus clock.  The formula for the internal frequency is:
     f(icgout) = (243000/7) * 64 * N/R, where N/R is the final multiplier. Bus Clock = f(icgout)/2. 
In my example, P/N = 4.  If you want 7.7MHz for f(icgout), then N/R = 7 * 7.7MHz /(243000 * 64) = 3.47.
 
If you select "3", then the untrimmed frequency will be (approx) 6.67MHz and Bus Clock = 3.33MHz--not what you want, so trimming will be required.  You need to set the N/R bits in ICGC2 as follows:
 
For N = 6, MFD bits (6:4) = 001B (binary)
For R = 2, RFD bits (2:0) = 001B 
 
So for ICG2, a value of 0x11 should work. This results in the following lines in the init file:
 
WRITE_BYTE_AND_SYNC=08/00000048/      ;  unchanged  
WRITE_BYTE_AND_SYNC=11/00000049/      ;  selects 6/2 = 3 for multiplier 
HCS08_TRIM=004E/FFBE/00757E20/             ;  7.7MHz => 3.88 Bus Clock
 
Remember that this entire process is for the purpose of generating a trim value ONLY.  You must still load the value from memory and place your values into ICG1 and ICG2 in your code.  
 
If you haven't already, you might want to download "MC9s08AW60.PDF" from documents area. 
Chapter 8 covers clock generation in good detail.
 
-------------
0 Kudos

1,189 Views
FordFairlaneBen
Contributor I
Hi everyone:
 
I have uncommented next lines and set that values in files 90s08AWxx.s8p and now it makes the trimming properly.
 
WRITE_BYTE_AND_SYNC=28/00000048/  ;Internal clock source
WRITE_BYTE_AND_SYNC=55/00000049/  ;Bus Clock = 486Khz
HCS08_TRIM=004E/FFBE/00076A70/    ;Trim the device
WRITE_BYTE_AND_SYNC=50/00000049/  ;Bus Clock = 15552Khz
Thank you very much for all, your wiseness have driven me to the right path.
best regards.
0 Kudos

1,189 Views
bigmac
Specialist III
Hello,
 
Have a look at the following old thread - it may explain the problem you are experiencing for the AW60.
 
 
Regards,
Mac
 
0 Kudos

1,189 Views
thisobj
Contributor III
I never use the processor expert, but the following seems to work:
 
In the simulator/debugger menu, select "MultilinkCyclonePro | Advanced Programming/Debug Options".
The "Advanced Options" dialog box should then appear.
Check the box, "Calculate Trim and Program the Non-Volatile Trim Register".
 
Next, find the file, "9s08aw60.s8p"  -- on my system it is in "C:\Program Files\Freescale\CW08 V5.0\prog".
 
For 4MHz Bus Clock ( 8MHz system clock), uncomment the following lines and make the following changes:
 
  WRITE_BYTE_AND_SYNC=08/00000048/  ; ICGC1: FLL engaged - internal reference
  WRITE_BYTE_AND_SYNC=00/00000049/  ; ICGC2: N/R = 4 => f(icgout) = approx. 8.8MHz
  HCS08_TRIM=004E/FFBE/003d0900/          ;Trim the device to 8MHz (Bus Clock = 4MHz = 0x3d0900 )
 
With the chip I'm currently using, the generated trim value is typically 0xE0.
 
Hope this helps.
 
 
0 Kudos

1,189 Views
FordFairlaneBen
Contributor I
Hi again:
Thank you very much for the reference of the Application note. It has been very useful but i can´t get fix the frequency of my MCU. I have used Processor Expert to generate the code and in the Reset task it appears this:
 
ICGTRM = *(unsigned char*)0xFFBE;    /* Initialize ICGTRM register from a non volatile memory */
I suposse that it´s correct and it copy the value of 0xFFBE into ICGTRM at the inizalitation but i  get the same frequency before. have I set any check box in Code Warrior (I´m using  Code Warrior 5.7.0)  to activate the calibration?.
Thank you very much.
Regards.
0 Kudos

1,189 Views
Blaise34
Contributor I
There is an AppNote AN2496 available at Freescale web site wich details the calibration of the ICG.
I hope it helps.
 
Blaise
0 Kudos