I was going to ask you to post the entire source unless it is somehow confidential.
It is a commercial product in development, so I don't want to publicly release the code for it. I realise that may seem rude when you guys are helping me.
Did you have a debugger? that would help.
Ummm... I don't know... The programmer is an AVRISPII.
Even though buttons have been re-invented any number of times, i understand if you don't want to disclose a commercial effort.
Re AVRISP - it is just a programmer, i.e. you don't have a debugger. Since this is a commercial effort you should make it a priority to get one and learn how to use it.
Any number of bugs can easily stay hidden in released code unless you have a proper test plan, and execute the plan as well. An integral part of all low level testing is debugging. Just as an example, i always walk through every algorithm i write, in the Studio simulator. First with inputs that make sense, to verify that the functionality is there (testing for functionality) then with inputs that don't make sense, to test for robustness and recovery from errors elsewhere (testing against bugs).
In by book anyone who develops commercial software should understand the principle of the V model of quality assurance
https://en.wikipedia.org/wiki/V-Modelwhether they actually use one of its many variants or not. While a relatively waterfall-ish model that seems ill suited to modern agile ways of working such as scrum, it is relatively easily integrated into cyclical development as well. In practice you have to go through the phases anyway in order to have a verified end result ready for deployment.
See also
http://istqbexamcertification.com/what-is-v-model-advantages-disadvantages-and-when-to-use-it/