Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

AURIX™ Forum Discussions

IvanoBono
Level 3
10 sign-ins 10 replies posted 10 questions asked
Level 3

[TC377 - Illd]
good morning,
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?

0 Likes
4 Replies
Prudhvi
Moderator
Moderator 10 likes received 100 sign-ins 50 replies posted
Moderator

Hello,

Please refer to the below code example to CCU Init(or re-init) and adapt to your needs:

https://github.com/Infineon/AURIX_code_examples/tree/master/code_examples/CCU_Clock_1_KIT_TC375_LK

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.

Regards,

Prudhvi.

0 Likes
IvanoBono
Level 3
10 sign-ins 10 replies posted 10 questions asked
Level 3

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

0 Likes
Prudhvi
Moderator
Moderator 10 likes received 100 sign-ins 50 replies posted
Moderator

Hello,

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.

OR

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.

Regards,

Prudhvi.

0 Likes
IvanoBono
Level 3
10 sign-ins 10 replies posted 10 questions asked
Level 3

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)

0 Likes