Hello iRob,
On the "freeze up" problem, have you been able to identify that the firmware is still operating correctly, aside from the lack of response from the pushbuttons?
Does the project use an LED, or do you have a spare pin that an LED could be connected to, for diagnostic purposes? If so, you might modify the code for the following mutually exclusive tests -
1. At the completion of your initialisation code, flash the LED for a period of 100-200 milliseconds (making sure the COP is reset periodically during the delay period). You will be able to determine that the POR occurs properly, and that the remainder of the code does not cause COP timeout, i.e. only a single flash on power-up.
2. Set up a timing register that the timer overflow ISR will decrement each time it is entered, provided its value is not already zero. This will provide a timeout period in multiples of 20 milliseconds (for a TIM prescale of 1). Then at each commencement of the main loop, test for timeout (zero register value), and if so set the register for a suitable delay period and toggle the test LED. If the LED then continuously cycles, this will verify that the firmware remains operational, and does not head off to places unknown.
If both tests were to verify correct operation when the pushbuttons cease operation, this would localise the problem to the push button code. Are you using keyboard interrupts for this purpose, or are you polling the pushbuttons?
Regards,
Mac