Hi everybody,
i've been having some problems with the following piece of code. The uP is a mega644.
The USART is initialized as UART for 38400@16MHz, only for transmission.
However, if I try to send something to the UART, the 644 will go back to execute things at address 0x0000. The MCUSR shows that there is no external or power on reset source (it shows 0 as its value).
I might have a hardware problem maybe, or is it a mega644 bug?
here it's main.c
#include "globals.h" extern void mytest(void); int main() { u08 st = MCUSR; MCUSR = 0; UBRR0L = (unsigned char)(51); // inits midi! UBRR0H = (unsigned char)(51 >> 8); UCSR0A = (1<<U2X0); UCSR0B = (1<<TXEN0) ; UCSR0C = (1<<UCSZ01) | (1<<UCSZ00); setbit(DDRD,1); clrbit(DDRD,0); //fin usart init UDR0 = st; for(;;) { mytest(); //nada mas! } while(1); return 1; }
mytest.c
void mytest(void) { return; }
globals.h just defines testbit(), setbit(), etc. along with some types (u08, u16, etc).
If I don't call mytest() in main then everything is fine, the avr never goes back to the reset vector.
I already tried with two different atmega644, and the same applies to both of them.
Thanks!