LPC804 trim clock?

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

LPC804 trim clock?

781 Views
phatpaul
Contributor III

Is it possible to set a custom FRO frequency trim?

According to the manual, the bootloader loads factory trim values into the FRO.  Can we change those values to adjust the frequency slightly?

EDIT: or perhaps it's possible to trim the SysTick timer interval which FreeRTOS uses for timing?

0 Kudos
3 Replies

754 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello satsok_n,

I will help to check about this, while need some days, because we will have public holiday tomorrow, I will reply you

after come back .ASAP. Thanks for your understanding.

 

BR

Alice

 

0 Kudos

771 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello hatpaul,

 How about use the  API of  set_fro_frequency :

Alice_Yang_0-1643189752639.png

 

BR

Alie

 

0 Kudos

766 Views
phatpaul
Contributor III

Alice,

Thanks for the reply.  I did see that API of  set_fro_frequency() but it says pretty clearly that the options for frequency parameter are only: 18000 => 18MHz, 24000=>24Mhz, 30000=>30Mhz.

But since you (NXP TechSupport) suggested that I could use this to trim the frequency, I gave it a try.

I hacked the fsl_clock.c and changed:

 

/*! brief Set FRO oscillator output frequency.
 *  Initialize the FRO clock to given frequency (18, 24 or 30 MHz).
 * param freq, please reference clock_fro_osc_freq_t definition, frequency must be one of 18000, 24000 or 30000 KHz.
 *
 */
void CLOCK_SetFroOscFreq(clock_fro_osc_freq_t freq)
{
    g_Fro_Osc_Freq = (uint32_t)freq * 1000UL;
    LPC_PWRD_API->set_fro_frequency(30100000UL); //(uint32_t)freq); -HACKING!
}

 

 

The result is that the clock is running at 24MHz (not the expected 30.1MHz).  This is confirmed by my FreeRTOS xTaskGetTickCount() counting at 12.5ms instead of 10ms.  And the serial baud is lowered to 93000bps from 115200, a -20% decrease.

I also tried set_fro_frequncy(29900000UL), set_fro_frequncy(30001000UL), and set_fro_frequncy(29000000UL).  They all result in a 24MHz clock.  (I guess 24MHz is the default, so the API just silently fails and keeps the default?)

So as I had expected, the API is not allowing to trim the clock.  But I wasted some more of my time to confirm.

It seems like a lot of this chip is a "black-box" because the ROM handles clock and flash-write functions and only provides a limited API.  Why NXP doesn't allow direct access to the hardware for more fine-grained control?

EDIT: Maybe it's available on higher-cost chips?  This article references a FREQTRIM register on LPC chips, but it's not mentioned in the LPC804 manual.  https://community.nxp.com/t5/LPC-Microcontrollers-Knowledge/LPC-Regarding-to-Internal-Clock-Calibrat...

 

0 Kudos