Is there any way the MCU can tell if it is running with a BM connected?
Specifically interested in MCF51AC256, but it applies to 9S08 chips as well.
Bill
Hi Bill,
I don't think you can tell whether or not the BDM is connected, but you can often tell if the previous reset had been from the BDM. I say "often" because about 10% of the time my GB60 system detects the BDM reset as a ~RESET-pin reset instead of a BDM reset. Hopefully, that is fixed in later S08s and the ColdFire parts.
The reset-status-register (SRS), which would normally have one bit set which indicates the cause of the previous reset, is all zeros when the reset is from the BDM.
BTW: This also works with the HC08 family when running from the emulator (MMDS, MMEVS or FSICE). It is 100% reliable, as opposed to the S08GB60.
The reason I am interested is this... I am developing firmware to control some hardware
I'm also building at the same time. I have the code sprinkled with HALT instructions so
I can carefully single step over sections of code and make sure it's not doing something
destructive to the hardware being controlled.
I would like to arrange things so if the MCU starts up w/o the debugger, that I can make
it just spin in a loop or something, so it doesn't run ahead and do who knows what to
my hardware gadget.
Prompted by your post, I see there's a SRS_POR bit. If I detect that one, I could just spin in a loop.
Bill
Hi Bill,
Yes, that should work. However, I would also add some of the other bits as well, such as COP and LVI. You don't want a power-supply problem breaking you out of your loop.
Come to think of it, maybe any non-zero SRS should put you into that loop.
I do currently have tests on some of those bits, causing a HALT, so if I run off into
the twilight zone, bad opcode, address, etc. under the debugger, I can more easily
tell that's happened. Very handy.