TRM HOW CALCULATE this value?

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

TRM HOW CALCULATE this value?

Jump to solution
3,137 Views
yecosuma
Contributor III

 

i want USE ICG MODULE in FEI mode  to multiply the internal reference 243khz for achieve 5.4 Mhz bus frecuency.

 

 

I want obtain   the frequency to exactly 5.4 MHz. with the TRM .HOW CALCULATE the ICGTRM value? I must place this value in ICGTRM?

REFS IS SETTING IN 1 OR 0?

THANKS FOR YOU ANSWER

Labels (1)
0 Kudos
Reply
1 Solution
1,377 Views
bigmac
Specialist III

Hello,

 

You are incorrect!

 

You do not program any specific value to NVICGTRM flash location, but let the programmer itself do the trim calibration, and program the value that will give the "standard" reference frequency of 243kHz.  Note that this value is usually not $80.

 

Then during initialisation,

ICGTRM = NVICGTRM + 15;  // Provides custom reference frequency

 

 

Regards,

Mac

 

View solution in original post

0 Kudos
Reply
10 Replies
1,377 Views
pbouf
Contributor I

For the QE128, CodeWarrior 6.3 programs the TRIM value for you when you program the flash.

P&E Micro are also coming up with tools to compute/program a custom TRIM value.

0 Kudos
Reply
1,377 Views
bigmac
Specialist III

Hello,

 

I assume that you are still using the 'LC60 device.  The REFS control bit is important when using an external reference, to determine whether a crystal or an oscillator is in use.  For FEI mode, using the internal reference, this bit may be either state (don't care).

 

When the ICG trim value is determined during programming, the value to generate an internal reference frequency of 243kHz +/-0.5% will be programmed into flash address 0xFFBE (NVICGTRM).  Within the initialisation code, this value must then be transferred to the ICGTRM control register.

 

With a MDF setting for multiplication factor 10, and RFD setting for division by 2, the nominal bus frequency would be 5.554 MHz.  To reduce the bus frequency to 5.4 MHz, the period of the internal reference would need to increase by 2.85 percent, requiring an increase of the value written to ICGTRM.

 

Depending on the bus frequency accuracy that you require, it may suffice to add a constant amount to the NVICGTRM value, before writing the ICGTRM register, based on the nominal trim step size parameter.

 

However, to achieve better accuracy, you would need to provide your own calibration procedure using an external timing reference (such as AC mains frequency or SCI received baud rate).  But this adds considerable complication.

 

Regards,

Mac

 

0 Kudos
Reply
1,377 Views
yecosuma
Contributor III

very thanks for you answer

I know the default value in this register is ICGTRM=$80 THEN the value that  should I will to put is 2.85 of this value?

NVICGTRM=$7C   IS THE VALUE for obtain a approximation nearest ?  NEWLY  THANKS BIGMAC

0 Kudos
Reply
1,377 Views
bigmac
Specialist III

Hello,

 

I think that I should clarify what I really meant.

 

The POR default for ICGTRM is $80, however this will produce the untrimmed reference frequency, which may differ from the nominal frequency of 243kHz by up to 25 percent.  The internal reference now needs to be trimmed.

 

Assuming the trimming calibration has been done during programming, the flash location at $FFBE (NVICGTRM) will  contain a trim value, usually different than $80, that will trim the reference to 243kHz, and it is this value that is normally written to the ICGTRM register during initialisation.  If the trimming calibration has not been done, the flash address will contain the unprogrammed value of $FF.

 

In your case, you actually need a reference frequency of 236.3kHz to provide a bus frequency of 5.4MHz.  This will require a larger trim value than is present at $FFBE, to reduce the reference frequency.  Taking into account the trim range available, I would estimate that the value written to ICGTRM should be about decimal 15 larger than the value present at the $FFBE location.  However, you should check this experimentally during project development, to see whether this value provides the most accurate result.

 

Regards,

Mac

 

0 Kudos
Reply
1,377 Views
yecosuma
Contributor III

ummmmmmmmm

according your explication  

the value that I should to put in el NVICGTRM is 8F? it is true or I am wrong.

0 Kudos
Reply
1,378 Views
bigmac
Specialist III

Hello,

 

You are incorrect!

 

You do not program any specific value to NVICGTRM flash location, but let the programmer itself do the trim calibration, and program the value that will give the "standard" reference frequency of 243kHz.  Note that this value is usually not $80.

 

Then during initialisation,

ICGTRM = NVICGTRM + 15;  // Provides custom reference frequency

 

 

Regards,

Mac

 

0 Kudos
Reply
1,377 Views
yecosuma
Contributor III

thanks for your answer is very important for my this ; really I was wrong  :smileysurprised: , now understand better this modulo very thanks for all.

0 Kudos
Reply
1,377 Views
yecosuma
Contributor III

hello thanks for your answers are of very helpful for my ;

 

I dont understand because the value written to ICGTRM should be 15 larger than the value present at the  $FFBE location,

I dont  understand  which is the initial value that I should to put in NVICGTRM?

sorry for my ignorance :smileysad:

0 Kudos
Reply
1,377 Views
Darkn3ss
Contributor II

Hi there.  The nice thing about NVICGTRM is that it is factory trimmed before ever hitting your hands.  If you are developing with Freescale CodeWarrior 6.2 or 6.3 (possibly others, but I only have experience with these two), then the value will automatically be pulled and re-programmed when you program your chip within CW.

 

What I learned (the hard way) is that if you are programming for production, your program script must pull and copy NVICGTRM, because when you bulk-erase your flash memory, that value gets erased too.

 

Here is some code I put in all of my production code now.

 

//Copy TRM value.

ICGTRM = NVICGTRM;

 

//Verify that TRM value not erased.

if(ICGTRM == 0xFF)

{

    ICGTRM = 0x80;

}

 

This way your TRIM values will always be pulled in from the factory TRIM values, which I have had nothing but good experiences with.  We make a warmer product that is time sensitive, and I have never seen a board with more than 0.3% error in the oscillator.

 

I hope this helps.


Best of luck.

0 Kudos
Reply
1,377 Views
peg
Senior Contributor IV

Hello,

 

The value at NVICGTRM is normally set by the programming adapter/software. The value is calculated to cause the internal oscillator to run at a pre-determined frequency. If your hardware/software does not do this for you and you need a accurate frequency then you will have to do this as a separate operation. The value that may be already programmed there is done at a specific voltage and temperature and may not be suitable for your case.

If the frequency of operation is not reachable by the normal setup it is possible to use the trim register to offset the oscillator frequency from the "normal" in order to achieve your own custom frequency. In order to utilise the "automatic" trim calculating facility of your programmer it is normal to allow this to still occur but add in the offset when the value is moved from the NV register into the working one.

BTW, I do not agree with the oft quoted methods of checking for the NV value to be programmed and then if not allowing the working register to be $80. If $80 is good enough for you sometimes it is good enough always! Either allow the $FF value to be transferred and stop SCI comms from working (or similar) or detect the failure to programme the trim and indicate it to the tester somehow.

0 Kudos
Reply