Program randomly hangs on MCLR reset
Posted: Sat Jul 05, 2014 8:55 pm
Hello
I have come across some odd behaviour usung MCLR with my program. Sometimes the program will not restart on the first MCLR reset, other times I can hit the switch 20+ times before this happens. A user would rarely use MCLR, but I would like it to be reliable. Once it does happen the program will not run again until a power on reset occurs. This occurs both with and without using a bootloader. MCLR still functions when this condition is present because if I pull up the bootloader entry pin, the bootloader will start after I again press the the MCLR switch. If I then remove the bootloader entry jumper and press MCLR, the program still will not run after the bootloader jumps to it.
This is running on a 18F14K50 with the following FC components: 2xADC, EEPROM, I2C, a momentary switch, 2 LEDs The main loop uses only the 2 ADCs, 1 LED and I2C. So these could be interrupted by the MCLR reset. Is there something that needs to be cleared on a restart that is not cleared on a MCLR reset? I have reviewed the datasheet and do not see an obvious cause. Seems to be I2C related as it does not hang if I disable the I2C stuff(DAC writes) in the main loop.
edit: Now I am thinking that this is because the I2C slaves are not also reset when the PIC is reset.
Regards,
Grant
I have come across some odd behaviour usung MCLR with my program. Sometimes the program will not restart on the first MCLR reset, other times I can hit the switch 20+ times before this happens. A user would rarely use MCLR, but I would like it to be reliable. Once it does happen the program will not run again until a power on reset occurs. This occurs both with and without using a bootloader. MCLR still functions when this condition is present because if I pull up the bootloader entry pin, the bootloader will start after I again press the the MCLR switch. If I then remove the bootloader entry jumper and press MCLR, the program still will not run after the bootloader jumps to it.
This is running on a 18F14K50 with the following FC components: 2xADC, EEPROM, I2C, a momentary switch, 2 LEDs The main loop uses only the 2 ADCs, 1 LED and I2C. So these could be interrupted by the MCLR reset. Is there something that needs to be cleared on a restart that is not cleared on a MCLR reset? I have reviewed the datasheet and do not see an obvious cause. Seems to be I2C related as it does not hang if I disable the I2C stuff(DAC writes) in the main loop.
edit: Now I am thinking that this is because the I2C slaves are not also reset when the PIC is reset.
Regards,
Grant