MCLR Reset - Please Explain
Posted: Fri Sep 18, 2009 2:14 pm
Hi,
I have written a simple program that reads an eeprom address many times. I need to use 2 different loop vars in order to count high enough. I have a block at the top if the flowchart to init the first loop var (Loop_1 type INT) to it's proper value of -30000. With each loop I INC Loop_1 until I reach +30000. Then I INC Loop_2 (BYTE) and go back and re-init loop_1 to -30000 and start over. I do this until Loop_2 reaches 50.
Since Loop_2 needed to start at 0 I did not put it into the Int block at the top of the flowchart.
The first time I run the program it appears to run fine, it takes about 20 seconds to read this eeprom address 60000 * 50.
If I press reset PB (MCLR to ground), the program starts and appears to be done almost instantly, should have taken about 20 seconds.
I then went back into the program and added Loop_2 = 0 to the init block.
Now when I run the program via HW reset it appears to work properly.
I assumed (shame on me) that the program area of the PIC would be reset on a HW reset. It appears that it does not reset.
1) Am I correct in my findings that pressing the reset button does not reset all program VARS?
2) If I am correct in 1 above, other than unplugging power to the PIC, is there a way to force the PIC to fully reinitialize?
Thank you,
Ron
I have written a simple program that reads an eeprom address many times. I need to use 2 different loop vars in order to count high enough. I have a block at the top if the flowchart to init the first loop var (Loop_1 type INT) to it's proper value of -30000. With each loop I INC Loop_1 until I reach +30000. Then I INC Loop_2 (BYTE) and go back and re-init loop_1 to -30000 and start over. I do this until Loop_2 reaches 50.
Since Loop_2 needed to start at 0 I did not put it into the Int block at the top of the flowchart.
The first time I run the program it appears to run fine, it takes about 20 seconds to read this eeprom address 60000 * 50.
If I press reset PB (MCLR to ground), the program starts and appears to be done almost instantly, should have taken about 20 seconds.
I then went back into the program and added Loop_2 = 0 to the init block.
Now when I run the program via HW reset it appears to work properly.
I assumed (shame on me) that the program area of the PIC would be reset on a HW reset. It appears that it does not reset.
1) Am I correct in my findings that pressing the reset button does not reset all program VARS?
2) If I am correct in 1 above, other than unplugging power to the PIC, is there a way to force the PIC to fully reinitialize?
Thank you,
Ron