I have an ATMega8 on which I have loaded some code that will take commands via usart and operate/rotate a servo.
On power up the servo controller code is in an OFF state; meaning that chip will not accept commands from the PC. I have a momentary switch connected to an input pin. When the pin is pressed the ON/OFF state toggles from OFF to ON. While OFF no commands are accepted. On start-up or reset, the code will send a message to the PC terminal indicating that the current ON/OFF state - using printf() - stating that "The ServoController is currently OFF. Press Button to turn ON."
The code seems to work as intended, with the following glitch - On startup, I am getting the startup message twice. On reset, I only get it once. So I am guessing that for some reason, on startup the ATMega8 is rebooting?
I am using an external 16 MHZ clock - crystal oscillator. My fuse setting is "6 CK 65 ms - Slowly rising power."
I had the servo wired to its own power source, but had the ground for that power source and the ground for the ATMega8 circuit connected. This is the configuration that seemed to work correctly when I was experimenting with the servo without implementing the usart to communicate commands (I was using the momentary switch instead). However, to see if the servo circuit was the source of - or a contribution to - the issue I am having, I disconnected it from the circuit and ran the code with just the chip. The result was the same.
In am not sure that the code is important, and it is long, so I am not posting it here. If I am mistaken in this respect, and seeing the code would be helpful, let me know and I will do so.
Any idea as to what might be causing the reboot on power up?