In Teensyduino's cores/teensy4/startup.c, the reset ISR void ResetHandler(void) has the following surprise:
It occurs immediately after setting the ARM PLL and core frequencies.
I'm curious what its purpose is, what problem is it alleviating, and if other software reset handlers need to mimic this to avoid a known pitfall?
Code:
...
configure_cache();
configure_systick();
usb_pll_start();
reset_PFD(); //TODO: is this really needed?
#ifdef F_CPU
set_arm_clock(F_CPU);
#endif
[B] asm volatile("nop\n nop\n nop\n nop": : :"memory"); // why oh why?[/B]
// Undo PIT timer usage by ROM startup
CCM_CCGR1 |= CCM_CCGR1_PIT(CCM_CCGR_ON);
PIT_MCR = 0;
PIT_TCTRL0 = 0;
PIT_TCTRL1 = 0;
PIT_TCTRL2 = 0;
PIT_TCTRL3 = 0;
...
It occurs immediately after setting the ARM PLL and core frequencies.
I'm curious what its purpose is, what problem is it alleviating, and if other software reset handlers need to mimic this to avoid a known pitfall?