If I power up my board the code runs but not properly, it appears to skip through delay routines instantly which is preventing correct initiation of some of the external devices. ...but if I then use the reset button on the board everything works fine. The uc is a Philips 80C31 running at 11MHz. The board has the reset circuitry as per the data sheet. Does anyone have any ideas as to what is going on here and what I can do to fix it? - I am going to try a longer RC period on the reset pin. Many thanks
If I power up my board the code runs but not properly, it appears to skip through delay routines instantly which is preventing correct initiation of some of the external devices. ...but if I then use the reset button on the board everything works fine. Best guess: You do not initialize the delay variable in RAM. The code runs after reset, get to where init takes place and when you push the reset button, the variable has been initialized. is this assembler or C? Erik
Hi Neil, Just a suggestion - unfortunatly I am unable to test if true - but is it possible that the compiler is optimising out the delay? Consider if you have the the following:-
int delay; for (delay = 0; delay <= 32000; delay++) { /* dummy loop to provide delay */ /* with either nothing inside the loop */ /* or something eg. x=delay; that the compiler can safely be mode outside the loop */ }
Months later I hit the same problem on a different product. The fix this time was to remove the resistor on the standard RC reset circuit. According to the data book the resistor is not necessary with the Philips 80C31 due to parasitic resistances within the device itself. Having removed the resistor the board now boots and runs correctly. This suggests that the 80C31 was not being reset correctly at power up, the RC time being too short. Removing the resistor will have increased the power on reset delay. Curious that some of the code worked correctly though.
"Curious that some of the code worked correctly though." Bad reset problems seem to be just as unpredictable as things like a corrupt stack. You just never really know what's going to happen. The usual advice is to use a reset supervisor IC rather than an RC reset circuit.