Hello, I am trying to switch to HFXOSC with the following code:
volatile uint32_t * pll_reg = (volatile uint32_t *) PRCI_PLLCFG;
volatile uint32_t * high_freq_reg = (volatile uint32_t *) PRCI_HFROSCCFG;
volatile uint32_t * spi0 = (volatile uint32_t *) 0x10014000;
#ifdef USE_HFROSC
/* Setting up osc frequency */
uint32_t tmp_reg = 0;
/* Install divider in high frequency oscillator */
tmp_reg |= (HFROSC_DIV_VAL & 0x2f) << HFROSC_DIV_OFFSET;
tmp_reg |= (HFROSC_TRIM_VAL & 0x1F) << HFROSC_TRIM_OFFSET;
tmp_reg |= (HFROSC_EN_VAL & 0x1) << HFROSC_EN_OFFSET;
(*high_freq_reg) = tmp_reg;
while (( (*high_freq_reg) & ((HFROSC_RDY_VAL & 0x1) \
<< HFROSC_RDY_OFFSET)) == 0 ) {
;
}
#endif /* USE_HFROSC */
#ifdef USE_HFXOSC
volatile uint32_t * ext_freq_reg = (volatile uint32_t *) PRCI_HFXOSCCFG;
(*ext_freq_reg) |= ((HFXOSC_EN_VAL & 0x1) << HFXOSC_EN_OFFSET);
while (( (*ext_freq_reg) & ((HFXOSC_RDY_VAL & 0x1) \
<< HFXOSC_RDY_OFFSET)) == 0 ) {
;
}
(*spi0) = 8;
(*high_freq_reg) &= ~(0x1 << HFROSC_EN_OFFSET);
#endif /* USE_HFXOSC */
#ifndef USE_PLL
/* Disable PLL */
(*pll_reg) &= ~(0x1 << PLL_SEL_OFFSET);
#else
#endif
But when I am trying to turn off HFROSC, openOCDs starts to output:
Info : dtmcontrol_idle=5, dbus_busy_delay=3, interrupt_high_delay=226
Info : dtmcontrol_idle=5, dbus_busy_delay=4, interrupt_high_delay=226
Info : dtmcontrol_idle=5, dbus_busy_delay=5, interrupt_high_delay=226
Info : dtmcontrol_idle=5, dbus_busy_delay=6, interrupt_high_delay=226
Info : dtmcontrol_idle=5, dbus_busy_delay=7, interrupt_high_delay=226
Info : dtmcontrol_idle=5, dbus_busy_delay=8, interrupt_high_delay=226
Info : dtmcontrol_idle=5, dbus_busy_delay=9, interrupt_high_delay=226
…
At the same time, I can change the frequency of HFROSC. As you can see, I have also tried to change an spi0 divider value.
What can be the reason of such behavior?