microcontroller frozen after hardware reset.

Thread Starter

testuserabcdef

Joined Jul 12, 2016
127
I'm using an AT89S52 microcontroller, and when I hooked the power up, the chip did respond to key presses, however, when I issued a reset (shorted the 2.2uF capacitor between reset pin and VCC), the results appeared to be stalled, and the micrcontroller ignored button presses, and the only way to get it to respond is to remove the power, wait a few minutes and re-apply power.

I checked the manual and it talks about watchdog timer and idle/power down mode, but I never enabled those modes, but I did however initialize all the variables at the beginning of my program. Is there anything I can do to fix this? (like is there anything I can do to force watchdog and power down mode or idle mode to be disabled?)
 

cmartinez

Joined Jan 17, 2007
8,220
I'm using an AT89S52 microcontroller, and when I hooked the power up, the chip did respond to key presses, however, when I issued a reset (shorted the 2.2uF capacitor between reset pin and VCC), the results appeared to be stalled, and the micrcontroller ignored button presses, and the only way to get it to respond is to remove the power, wait a few minutes and re-apply power.

I checked the manual and it talks about watchdog timer and idle/power down mode, but I never enabled those modes, but I did however initialize all the variables at the beginning of my program. Is there anything I can do to fix this? (like is there anything I can do to force watchdog and power down mode or idle mode to be disabled?)
What sort of oscillator are you using, internal or external? At what frequency? What exact model of oscillator?
 

Thread Starter

testuserabcdef

Joined Jul 12, 2016
127
20Mhz crystal attached to xtal1 and xtal2 pins through 1cm by 5mm thick PCB traces and each pin is grounded through 33pF capacitors. I wonder if I picked the wrong capacitor value
 

cmartinez

Joined Jan 17, 2007
8,220
20Mhz crystal attached to xtal1 and xtal2 pins through 1cm by 5mm thick PCB traces and each pin is grounded through 33pF capacitors. I wonder if I picked the wrong capacitor value
Maybe you did, can you post the MCU's spec sheet?... and also the crystal's specs. They too have inherent capacitance that could be affecting the circuit.

Worst case scenario would be that you bought a powered cristal oscillator, and connected it to the Xtal1 pin, leaving Xtal2 unconnected. No capacitors would be needed using that setup.
 

Thread Starter

testuserabcdef

Joined Jul 12, 2016
127
Theres not enough info on the crystal for me to find a datasheet for it. I'm curious. can I calculate the capacitor values required for the crystal based on an impedance required through them regardless of crystal frequency without requiring a datasheet for the crystal?
 

cmartinez

Joined Jan 17, 2007
8,220
Theres not enough info on the crystal for me to find a datasheet for it. I'm curious. can I calculate the capacitor values required for the crystal based on an impedance required through them regardless of crystal frequency without requiring a datasheet for the crystal?
It's not about the crystal's frequency, as long as it works within the MCU's specs (even up to 10% overclocking is fine). But there are crystals out there that have inherent capacitance, and that could be an issue. That's why I suggest you get an oscillator and replace the crystal. That would be the sure way to go.
 

DickCappels

Joined Aug 21, 2008
10,152
Besides a capacitor from the RESET pin to Vcc you also need:
• the resistor to ground to charge the capacitor, taking the RESET pin low,

• A diode across the resistor to speed up the discharge of the capacitor when the power is switched off <= sometimes needed depending on how quick you want the RESET circuit to recover,

• A load on the power supply other than the microcontroller to assure the power supply goes low enough to discharge the capacitor enough so that it pulls the RESET pin to logic high when the power is switched back on. Sometimes active power supply pull-down is used rather than a resistor.

Do you have all of these things?

It might also help if you can post a schematic diagram.
 

Thread Starter

testuserabcdef

Joined Jul 12, 2016
127
I'm going to keep checking my code because when I issue a reset, the first part of my code always initializes correctly on every reset, but the subsequent parts dont.
 

RamaD

Joined Dec 4, 2009
328
Are you using a LCD display? If you are using one, you need to init the display by 'initialize by instruction' after a soft restart. The LCD Module gets initialized by power on, but not when you are issuing a reset by pulling reset active. So, the uC could be waiting for LCD to be ready, which it will not after a reset.
 

Thread Starter

testuserabcdef

Joined Jul 12, 2016
127
I also use LEDs for output but I fixed my problem. I checked my board and noticed 3 adjacent tracks 10 mils width 10 mils apart were shorted with a tiny blob of solder. As soon as I removed the short, the board started working. Thanks for the suggestions .
 

cmartinez

Joined Jan 17, 2007
8,220
I also use LEDs for output but I fixed my problem. I checked my board and noticed 3 adjacent tracks 10 mils width 10 mils apart were shorted with a tiny blob of solder. As soon as I removed the short, the board started working. Thanks for the suggestions .
Yeah... those annoying, almost invisible shorts between traces... been there...
 
Top