Thanks for the reply. There's two issues here that may or may not be related. The issue that's the topic of this thread of course but the primary, critical problem I've been working on tracking down is that the micro may exhibit this behavior -- unresponsive, almost like it's not running code at all -- when at customer sites. When we get the unit back here for FA we find the micro is drawing power from the battery at a rate that's less than 50% of its normal current draw but does not appear to be actually doing anything. In my start up code, I've got one potential trap:
Code:
void InitializeMachine( void ){ //safe system IOs first InitIOs(); //system options, clock generation SOPT = initSOPT; ICGC2 = initICGC2; ICGC1 = initICGC1; while( !ICGS1_LOCK ) { //DEBUG prtG_TP_PIN62 ^= 1; __RESET_WATCHDOG(); //reset COP while waiting on FLL lock }//while ...
where, if the FLL fails to lock, the micro could get stuck here forever. So far I don't see any indication that this is the case though. There are no other such occurences of while loops where the COP is reset in this way.
The only way to recover these customer units seems to be to disconnect power (or have the battery die). While I cannot be sure it's not stuck in a "buzz loop", the current draw, at 6.9mA or so, doesn't match the draw of a micro whose ICG is not initialized further than self-clocked mode. The behavior of the micro in this condition is very much like when the BDC has the thing in active BDM, as if the user code isn't even running.
When I saw that I was able to induce very similar behavior by simply holding BKGD low during a reset -- ending up with a non-responsive micro that wouldn't even talk to a P&E USB multilink, I got suspicious that perhaps the micro is somehow ending up in a similar condition either through something I'm doing in my code or perhaps by bad power or levels on BKGD or other pins during power-on and -off transitions.
The problem is very rare. We have not yet intentionally induced it by doing normal things people might do with the product although maddeningly, they seem to have been able to get it to happen a couple of times now...
I have one unit in that state on my workbench and am attempting to find a way to see if I can see if the BDC is alive and read the BDCSCR to determine if the BDMACT bit is set indicating BDM mode is active. That would tell me alot.
So far I haven't been able to find a way to read this status non-intrusively via the Codewarrior IDE so I'm left with two options: attempt to craft up my own BDM interface (1/2 done) or see if there's a low-level API available for the P&E USB multilink that would allow me to ask it to do a SYNC and a READ_STATUS without disturbing the state of the micro by asserting reset.
You say that there have been previous discussions of the "it does not start without debugger attached" topic which sounds like it might be interesting: Do you have any links to these discussions?