Hi all:
In SDK 2.3, it provide CLOCK_SetupFROClocking API to setup FRO, the FRO have FREQTRIM field with factory trim for 96MHz FRO. I have two questions about this field and API:
1.If Select 48MHz FRO output, is the trim field same as 96MHz trim setting?
2.why SDK API could hard code the trim value? since factory trim, the trim value is maybe different.
thanks.
#define INDEX_SECTOR_TRIM48 ((uint32_t *)0x01000448U)
#define INDEX_SECTOR_TRIM96 ((uint32_t *)0x0100044CU)
/* Set FRO Clocking */
status_t CLOCK_SetupFROClocking(uint32_t iFreq)
{
uint32_t usb_adj;
if ((iFreq != 12000000U) && (iFreq != 48000000U) && (iFreq != 96000000U))
{
return kStatus_Fail;
}
/* Power up the FRO and set this as the base clock */
POWER_DisablePD(kPDRUNCFG_PD_FRO_EN);
/* back up the value of whether USB adj is selected, in which case we will have a value of 1 else 0 */
usb_adj = ((SYSCON->FROCTRL) & SYSCON_FROCTRL_USBCLKADJ_MASK) >> SYSCON_FROCTRL_USBCLKADJ_SHIFT;
if (iFreq > 12000000U)
{
if (iFreq == 96000000U)
{
SYSCON->FROCTRL = ((SYSCON_FROCTRL_TRIM_MASK | SYSCON_FROCTRL_FREQTRIM_MASK) & *INDEX_SECTOR_TRIM96) |
SYSCON_FROCTRL_SEL(1) | SYSCON_FROCTRL_WRTRIM(1) | SYSCON_FROCTRL_USBCLKADJ(usb_adj) |
SYSCON_FROCTRL_HSPDCLK(1);
}
else
{
SYSCON->FROCTRL = ((SYSCON_FROCTRL_TRIM_MASK | SYSCON_FROCTRL_FREQTRIM_MASK) & *INDEX_SECTOR_TRIM48) |
SYSCON_FROCTRL_SEL(0) | SYSCON_FROCTRL_WRTRIM(1) | SYSCON_FROCTRL_USBCLKADJ(usb_adj) |
SYSCON_FROCTRL_HSPDCLK(1);
}
}
else
{
SYSCON->FROCTRL &= ~SYSCON_FROCTRL_HSPDCLK(1);
}
return 0U;
}
Hi Dawei,
1.If Select 48MHz FRO output, is the trim field same as 96MHz trim setting?
TS: The factory trim value was saved at internal ROM address, the different frequency using the different address.
As macro definition,
#define INDEX_SECTOR_TRIM48 ((uint32_t *)0x01000448U)
#define INDEX_SECTOR_TRIM96 ((uint32_t *)0x0100044CU)
2.why SDK API could hard code the trim value? since factory trim, the trim value is maybe different.
TS: I did a test with two LPCXpresso54608 boards to call the same CLOCK_SetupFROClocking(48000000U) function,
the SYSCON_FROCTRL [FREQTRIM] bits with different value.
That means the there with different trim value during factory trim phase and storage at ROM address 0x01000448.
First board:
Second board:
Below is SYSCON_FROCTRL register value after call BOARD_BootClockFROHF96M() function:
Wish it helps.
Have a great day,
Mike
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------