XMC4500 Using System Reset to start CAN_BSL operation

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

cross mob
User5581
Level 3
Level 3
Hi All,

We are looking to reset the XMC4500 at run time and have it wake up in CAN_BSL startup mode.

Section 26.2.1 in the the XMC4500 reference manual (v1.5) indicates:
SWCON bitfield is read by firmware when the device emerges from a system reset. The
following table enlists the encoding of the SWCON bitfield and boot modes. In the event
when software does not explicitly program SWCON and a system reset is experienced,
values on TCK and TMS decide the boot mode.

The table (26-2) on the same page lists the value of SWCON[3:0] to be 0011 for CAN_BSL system reset boot mode.

To try to accomplish this, we wrote the following example code and executed it on an XMC4500F144K1024 step AC device:

#include //Declarations from DAVE3 Code Generation (includes SFR declaration)

int main(void)
{
uint32_t i;
DAVE_Init(); // Initialization of DAVE Apps
WR_REG(SCU_GENERAL->STCON,SCU_GENERAL_STCON_SWCON_Msk,SCU_GENERAL_STCON_SWCON_Pos,0x03UL); // Select CAN_BSL mode upon next system reset.
__NOP();
for(i=0; i<0x00400000; i++) // blink LED twice
IO004_SetOutputValue(IO004_Handle0, (0x00100000 & i) == 0 ); // P5.11 drives an LED.
NVIC_SystemReset();
while(1) {} // should never execute.
return 0;
}


Unfortunately, this code does not reset the MCU into CAN_BSL mode. The LED continuously blinks indicating that the reset is occurring repeatedly, but into normal boot mode. It is not pausing after NVIC_SystemReset() to listen for the CAN_BSL Init packets. In this case, we are not pulling up TCK and pulling down TMS at reset time. According to the reference manual section 26.2.1, we should not need to do so, as this is a system reset and not a PORST.

If I set a breakpoint on the __NOP(), I can see that the SWCON[3:0] bitfield has correctly been written into the STCON register to request CAN_BSL mode upon system reset.

We can successfully boot into CAN_BSL with a power-on reset by pulling up TCK and pulling down TMS, so we know that the system otherwise can perform a CAN_BSL operation successfully.

Can someone (perhaps at Infineon) help us to understand why this does not work, and suggest some code that does induce CAN_BSL mode at runtime?

Regards,
-Kurt
0 Likes
2 Replies
Not applicable
Hi Kurt,

I recommend you to place the configuration of "CAN BSL + System Reset" inside the External Interrupt Service Routine in order to avoid repetitive reset. For example, the interrupt will be triggered by pull P3.6 to "H".

SCU_GENERAL -> STCON = 0x300; /*Enable CAN BSL*/
SCU_RESET -> RSTCLR |= 0x1; /* Clear reset status */
PPB -> AIRCR |= 0x4; /* Trigger System reset */


You can refer to "ERU001_ERU002_Example2" for setup of external trigger event.

Best regards,
Sophia
0 Likes
User5581
Level 3
Level 3
Hi, Sophia,
From your example, I see that we need to do SCU_RESET -> RSTCLR |= 0x1; to clear the RSTSTAT bitfield before calling NVIC_SystemReset(). The startup software (SSW) examines SCU_RSTSTAT when coming out of reset to help decide the boot mode as mentioned in the XMC4500 Reference manual (v1.5) sec 26.2.3. I missed this detail earlier.

I am now successfully inducing CAN_BSL upon a system reset now. Thank you!

Best Regards,
-Kurt
0 Likes