I had a function :
void send2net(char * str) { char * p=str; while(*p!=0) { while((UCSR2A&(1<<UDRE))==0); // wait UDR empty UDR2=*p++; } } // end of send2net
I used it with ATmega324PB and is works well.
Now, I switch to ATmega4809 :
void send2net(char * str) { char * p=str; while(*p!=0) { while((USART1.STATUS&USART_DREIF_bm)==0); // wait UDR empty USART1.TXDATAL=*p++; } } // end of send2net
But it does not work a expected.
char hello1[]="Hello 1\n"; send2net(hello1); send2net("Hello 2\n");
I get :
Hello 1␊ <0xff><0xff><0xff><0xff><0xff><0xff><0xff><0xff><0xff>
My questions are :
- why inline string does not work as before as I use the same makefile (just change what's needed) ?
- why all bytes of the inline string is read as 0xff except the last one (as it exits send2net) ?
- why 9 * 0xff as "Hello 2\n" is only 8 characters (+ null char at the end) ?
- How to solve this ?
Thanks for your lights and help.
Doom