I have a custom design, connected with USB-C2D at Silabs IDE, part number of the cpu is EFM8BB31F64G. I cannot initialize and switch to 49mhz clock.
My code after reset contains initialisation of SFRPAGE, SP and disable WDT:
First try was with:
MOV CLKSEL,#000H ;use hfosc0, divided by 1
BTLD_WFDIVRDY1: MOV A,CLKSEL ;wait clock to propagate
MOV CLKSEL,#003H ; switch to hfosc1 div 1. When I execute step by step, after this instruction, the debugger hangs and the IDE becomes unresponsive, eventually it gives a disconnect message
BTLD_WFDIVRDY2: MOV A,CLKSEL ;wait for clock to propatate
I also tried to manually start both oscillators and leave them a delay to stabilize, before switching
MOV SFRPAGE,#PG2_PAGE //(0x10)
MOV SFRPAGE,#LEGACY_PAGE //(0x00)
Other code sequences works fine with clock on hfosc0.
Am I doing something wrong? Thank you.
Problem solved, the PFE0CN must be set to sysclk<50mhz before changing clock.
Good job! I'm marking your replace as the solution to this problem.