Hi, I changed my receive function into the following one, but when I use those receive/transmit function too many times in the same main, I keep receive strange things in my nios II console.
int receive(char *buffer){
int size=0,j=10000000;
alt_u8 status;
while(j){
status= IORD_ALTERA_AVALON_UART_STATUS(UART_BASE);
while(status & RRDY){ // check if reception ready{
buffer=IORD_ALTERA_AVALON_UART_RXDATA(UART_BASE);//receive character
status= IORD_ALTERA_AVALON_UART_STATUS(UART_BASE); //update status register
size++;
}
j--;
}
return size;
}
int main () {
char *buffer=malloc(200);
int size=0;
size=receive(buffer);
printf("%d\n%s",size,buffer);
return 0;
}
usually I use those functions in another C file.
I don't need an infinite loop in my function, because I have to use my receive/transmit over 10 times in the main function.