mirror of
https://gitea.osmocom.org/sim-card/simtrace2.git
synced 2026-03-16 21:28:33 +03:00
board_lowlevel.c: Improve main oscillator initialization
* ensure the PB8/PB9 pins are actually not in GPIO mode, which they apparently are on boot-up * ensure that neither pull-up nor pull-down are enabled on PB8/PB9 * ensure we first start the oscillator, before selecting it The sum of the above changes seems to make oscillator start-up much more reliable than before. The time needed for initialization is now pretty stable, and the occasional 15-20second clock stabiliziation has not been observed with this change.
This commit is contained in:
@@ -94,14 +94,17 @@ extern WEAK void LowLevelInit( void )
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* Initialize main oscillator */
|
/* Initialize main oscillator */
|
||||||
/* if ( !(PMC->CKGR_MOR & CKGR_MOR_MOSCSEL) )
|
if ( !(PMC->CKGR_MOR & CKGR_MOR_MOSCSEL) )
|
||||||
{
|
{
|
||||||
PMC->CKGR_MOR = CKGR_MOR_KEY(0x37) | BOARD_OSCOUNT | CKGR_MOR_MOSCRCEN | CKGR_MOR_MOSCXTEN;
|
PMC->CKGR_MOR = CKGR_MOR_KEY(0x37) | BOARD_OSCOUNT | CKGR_MOR_MOSCRCEN | CKGR_MOR_MOSCXTEN;
|
||||||
timeout = 0;
|
timeout = 0;
|
||||||
while (!(PMC->PMC_SR & PMC_SR_MOSCXTS) && (timeout++ < CLOCK_TIMEOUT));
|
while (!(PMC->PMC_SR & PMC_SR_MOSCXTS) && (timeout++ < CLOCK_TIMEOUT));
|
||||||
}*/
|
}
|
||||||
|
|
||||||
/* Switch to 3-20MHz Xtal oscillator */
|
/* Switch to 3-20MHz Xtal oscillator */
|
||||||
|
PIOB->PIO_PDR = (1 << 8) | (1 << 9);
|
||||||
|
PIOB->PIO_PUDR = (1 << 8) | (1 << 9);
|
||||||
|
PIOB->PIO_PPDDR = (1 << 8) | (1 << 9);
|
||||||
PMC->CKGR_MOR = CKGR_MOR_KEY(0x37) | BOARD_OSCOUNT | CKGR_MOR_MOSCRCEN | CKGR_MOR_MOSCXTEN | CKGR_MOR_MOSCSEL;
|
PMC->CKGR_MOR = CKGR_MOR_KEY(0x37) | BOARD_OSCOUNT | CKGR_MOR_MOSCRCEN | CKGR_MOR_MOSCXTEN | CKGR_MOR_MOSCSEL;
|
||||||
/* wait for Main XTAL oscillator stabilization */
|
/* wait for Main XTAL oscillator stabilization */
|
||||||
timeout = 0;
|
timeout = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user