I've built a couple of PIC systems that run for months on end (weather station and water pump controller) and noticed that they occasionally go wrong.
I have structured my software so that the initialisation (clock speed, data direction, ADC settings and so on) is first followed by a loop that does the work - this loop should execute 'for ever.'
Found this advice in the book 'Programming 16 Bit Microcontrollers' by Lucio Jasio:
1. It is likely, if the MCU runs for long enough, that power supply fluctuation (undetected by the 'brownout' reset circuit) or noise will corrupt the essential control registers/peripherals.
2. Prevent this by putting periodic 'refresh' code into your main loop.
Like most good ideas - it is obvious once someone points it out.
I've not seen this advice anywhere else in the few years I've been programming PICs. Any comments?
Regards Bill Legge
Bookmarks