Dawei You

SDK CLOCK_SetupFROClocking API of LPC546XX

Discussion created by Dawei You Employee on Mar 3, 2018
Latest reply on Mar 16, 2018 by Dawei You

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;
}

Outcomes