Update XTAL32M settings to the robust settings as recommended in the HW guidelines
ID: LPCBARESDK-859
Status: Fixed
First reported: 6.0.18.1182.1
Fixed in: 6.0.20.1338
Description
The default XTAL32M oscillator settings in the SDK6.0.18.1182.1 or earlier might lead in some cases to an interruption of oscillation
Workaround
Customers working with an earlier SDK version should change the current and amplitude settings of the XTAL32M. This fix will be included in the next release and we will introduce an improved current and amplitude setting for the XTAL32M oscillator.
XTAL32M_CTRL0_REG: CORE_CUR_SET = 1
XTAL32M_CTRL0_REG: CORE_AMPL_TRIM = 5
To achieve this, the SDK must be adapted in:
Location: sdk/platform/arch/main
Filename: arch_system.c
API name: system_init()
--- arch_system.c 2022-12-01 15:20:54.739927400 +0100
+++ arch_system.c 2022-11-23 18:05:32.000000000 +0100
@@ -1268,8 +1268,7 @@
// Configure XTAL32M
SetBits16(TRIM_CTRL_REG, XTAL_TRIM_SELECT, 2); // only CLK_FREQ_TRIM_REG will be used for XTAL32M trimming
SetBits16(XTAL32M_START_REG, XTAL32M_START, 0);
+ SetBits16(XTAL32M_CTRL0_REG, CORE_CUR_SET, 1);
+ SetBits16(XTAL32M_CTRL0_REG, CORE_AMPL_TRIM, 5);
- SetBits16(XTAL32M_CTRL0_REG, CORE_CUR_SET, 2);
#else
// Confirm XTAL16M calibration
xtal16m_calibration_check();
And
Location: sdk/platform/arch/main
Filename: arch_hibernation.c
API name: arch_hibernation_restore()
@@ -335,8 +335,7 @@
// Configure XTAL32M
SetBits16(TRIM_CTRL_REG, XTAL_TRIM_SELECT, 2); // only CLK_FREQ_TRIM_REG will be used for XTAL32M trimming
SetBits16(XTAL32M_START_REG, XTAL32M_START, 0);
+ SetBits16(XTAL32M_CTRL0_REG, CORE_CUR_SET, 1);
+ SetBits16(XTAL32M_CTRL0_REG, CORE_AMPL_TRIM, 5);
- SetBits16(XTAL32M_CTRL0_REG, CORE_CUR_SET, 2);
if ((clk_ctrl_reg_backup & RUNNING_AT_XTAL32M) == RUNNING_AT_XTAL32M)
{
Additionally, make sure not to set the CLK_FREQ_TRIM_REG
to 0x0 before going to sleep in:
Location: sdk/platform/arch/main
Filename: arch_main.c
API name: arch_switch_clock_goto_sleep()
delete
@@ -340,6 +340,9 @@
#else
while( (GetWord16(CLK_CTRL_REG) & RUNNING_AT_RC16M) == 0 );
#endif
- SetWord16(CLK_FREQ_TRIM_REG, 0); // Set zero value to CLK_FREQ_TRIM_REG
- // Do not disable the XTAL16M (DA14585/586) or XTAL32M (DA14531).
- // It will be disabled when we sleep...
#endif // (USE_POWER_OPTIMIZATIONS)
}
}
Reference
Refer to the section 3.2.2.2 in AN-B-075 : DA14531/530 Hardware Guidelines