cancel
Showing results for 
Search instead for 
Did you mean: 

SPC570Sxx: Bootloader and SWT

LeoC
Associate II

Hi,

My setup:

  • SP570S-DISP Demo Board Evaluation
  • uC: SPC570S50E1
  • IDE: SPC5Studio 5.8.1

I'm started from example "SPC570Sxx_RLA Bootloader Application for Discovery".

I modified the example in order to have the possibility to update the firmware using both CAN and SERIAL.

If the first packet is a CAN packet, firmware update procedure starts using CAN .

Instead, If the first packet is a SERIAL packet, firmware update procedure starts using SERIAL.

Everything works as expected.

After that, I added the SWT (Software Watchdog Timer).

Below, "init" function and "feed" function.

#define WDT_SR_WSC_UNLOCK_SEQ1		0xC520
#define WDT_SR_WSC_UNLOCK_SEQ2		0xD928
 
#define WDT_SR_FIXED_SERVICE_SEQ1	0xA602
#define WDT_SR_FIXED_SERVICE_SEQ2	0xB480
 
void wdt_init(void){
	SWT_0.SR.R = WDT_SR_WSC_UNLOCK_SEQ1;
	SWT_0.SR.R = WDT_SR_WSC_UNLOCK_SEQ2;
 
	/* Check soft lock bit */
	while (SWT_0.CR.B.SLK == 0x1);
 
	/* Configure timeout register (TO) */
	SWT_0.TO.R = WDT_TO_1_SEC;
 
	/* Configure control register (CR) */
	SWT_0.CR.R 	   = 0xFF000008; 	/* MAPn = Default value */
	SWT_0.CR.B.WEN = 0x01;			/* 1 SWT is enabled */
	SWT_0.CR.B.FRZ = 0x01;			/* 1 SWT counter is stopped in debug mode */
	SWT_0.CR.B.STP = 0x01;			/* 1 SWT counter is stopped in stop mode */
	SWT_0.CR.B.ITR = 0x00;			/* 0 Generate a reset on a time-out */
	SWT_0.CR.B.WND = 0x00;			/* 0 Regular mode, service sequence can be done at any time */
	SWT_0.CR.B.RIA = 0x01;			/* 1 Invalid access to the SWT causes a system reset if WEN=1 */
	SWT_0.CR.B.SMD = 0x00;			/* 00 Fixed Service Sequence, the watchdog is serviced by writing the fixed sequence 0xA602, 0xB480 to the SWT_SR */
}
 
void wdt_feed(void){
	SWT_0.SR.R = WDT_SR_FIXED_SERVICE_SEQ1;
	SWT_0.SR.R = WDT_SR_FIXED_SERVICE_SEQ2;
}

But, watchdog doesn't work.

I tested these functions (wdt_init and wdt_feed) in an another application and everything works.

But inside bootloader, it doesn't work!

Please, could you help me?

Thanks

Leo

This discussion has been locked for participation. If you have a question, please start a new topic in order to ask your question
2 REPLIES 2
zambrano.luigi
Senior III

Hi Leo,

please, could you clarify me the following points?

  1. When you said that your code works fine in another application, do you mean that you have checked it in another SPC5Studio application?
  2. In which part of the bootloader do you expect that the SWT generates a reset? Can you clarify me the execution flow?
  3. Could you add the following instructions

MC_RGM.FES.R = 0xFFFFU;

MC_RGM.DES.R = 0xFFFFU;

at the start of wdt_init function and check if the issue is solved?

Regards,

Luigi

ilcontefabio
Associate II

Hi,

sorry to post again in this old one but I'm intereste dabout the tool you use for download the new firmware via can bus

thanks

Fabio