[TC377 - Illd]
i am developing a bootloader.
the bootloader initializes the system clock and peripheral clock, and after some checks, disables interrupts and starts the user application. the user application reinitializes the clocks, but at the end of the initialization I find myself with the register SCU_CCUCON0.CLKSEL: 00 which indicates that I am using the backup clock.
I understood that before starting the user application I should reset the clock to default values: what should I do?
Please refer to the below code example to CCU Init(or re-init) and adapt to your needs:
In your User application you may adapt the code based on the above iLLD code example to configure the SCU_CCUCON0 to the intended Clock source.
thanks for the answer, I had already seen the example, but the user app code is not developed by me, so I need a procedure to de-initialize the clock before transferring control to the user app, so that the user app finds a situation with the values of the registers of clock to default
1. You could either modify the Register values of the Clocks to the Reset value as specified in the User Manual for each register before jumping to Application.
2. At the end of the Bootloader you may perform a SW based Reset by storing the BL Initialization status in a RAM area that is not affected by SW issued Reset. This sets the register values to the default value automatically and based on the flag you either go to BL or Application.
I'm going to proceed with solution 1.
I tried to reset the System and Peripheral PLL to default values with this code:
uint16_t endInitSafetyPassword = IfxScuWdt_getSafetyWatchdogPassword(); IfxScuWdt_clearSafetyEndinit(endInitSafetyPassword); SCU_PERPLLCON0.U=0x00003A00; //restore default SCU_PERPLLCON0 while(SCU_CCUCON0.B.LCK); /* Wait for CCUCON0 unlocked */ SCU_CCUCON0.B.UP = 1; /* Update */ SCU_SYSPLLCON0.U=0x40003A00; //restore default SCU_SYSPLLCON0 while(SCU_CCUCON0.B.LCK); /* Wait for CCUCON0 unlocked */ SCU_CCUCON0.B.UP = 1; /* Update */ IfxScuWdt_setSafetyEndinit(endInitSafetyPassword);
but work only if i start in bootloader with backup clock.
if in bootloader i configure ext oscillator, I can't go back to the backup clock, and if I don't, when the user application starts up and reconfigures the PLLs I end up using the backup clock (I guess it generates an error forcing the switch)