SRS=0 safe to detect BDM operation?

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

SRS=0 safe to detect BDM operation?

974 次查看
Obetz
Contributor III

Hello All,

 

to detect whether a target is run under BDM control, my code checks whether SRS is zero.

 

This way I enable some workarounds in the code during BDM debug sessions (i.e. a loop instead of WAIT because my debugger dislikes WAIT).

 

Is this a safe method? IOW is it guaranteed that SRS is not zero if I don't run the target under BDM control?

 

Some of the workarounds should not be run in production mode because they make the product less stable.

 

Oliver

标签 (1)
0 项奖励
5 回复数

522 次查看
rocco
Senior Contributor II

Hi Oliver,

 

Here are a few things that I have learned.

 

I know that the SRS register behavior is different between the HC08GP32 and the S08GB60, so it may matter which derivative you are using.

 

On the GB60, the SRS register is not consistent when I reset/restart the firmware from the BDM. Most of the time I get zero in the SRS, but sometimes I get the "Reset-Pin" reset bit set in the SRS instead.

 

Though I don't have a lot of field hours on the GB60 yet, I have yet to see the SRS come up zero when the BDM was not attached.

0 项奖励

522 次查看
Obetz
Contributor III

Hello rocco,

 

good to know that "debug mode" might be undetected. This migt be a minor nuisance during debugging.

 

Nevertheless I hope that I don't get SRS=0 without BDM. What do you think?

 

 

Oliver

0 项奖励

522 次查看
kef
Specialist I

Don't know which part you are talking about, but it is specified that S08D FTRIM is loaded from flash on reset into normal mode. Resetting into BDM mode, FTRIM is loaded with 0x80. This can be used to determine mode, but only if NVTRIM is not 0x80.

 

0 项奖励

522 次查看
Obetz
Contributor III

Hello kef,

 

did you test this?

 

The MC9S08DZ60 data sheet states "The MCU will not automatically copy the values in these FLASH locations to the respective registers. Therefore, user code must copy these values from FLASH to the registers". The SH and SG also doesn't copy the values from Flash to the clock registers.

 

Oliver

0 项奖励

522 次查看
kef
Specialist I

You are right. I found this notice in DZ128 datasheet, and though it applies to whole family. D60 datasheet doesn't have this notice:

 

  • A value for TRIM is loaded during reset from a factory programmed location when not in any BDM mode. If in a BDM mode, a default value of 0x80 is loaded.

0 项奖励