#define DATA_LIMIT 100 //for example, check your available RAM
volatile char rx_data[DATA_LIMIT]; //buffer
volatile unsigned int drc=0; //rx fill pointer
volatile unsigned int dsc=0; //rx read pointer
ISR(USART0_RX_vect){
char data;
//RXC0 got 1, recieved data
data=UDR0;
rx_data[drc++]=(data);
if (drc>=(DATA_LIMIT))drc=0;
}
uint8_t usart_receive( void ){
char data;
while(drc==dsc); //wait for data if there isn't data in buffer
data=rx_data[dsc++];
if (dsc>=(DATA_LIMIT))dsc=0;
return data;
}
//you don't like to wait for data? ask first!
uint8_t usart_kbhit( void ){
return (drc!=dsc);
}
... and some where in your main program (after your init)...
uint8_t W_buffer[8];
int i;
for (i=0;i<8;i++)
{
W_buffer[i]=usart_receive(); //should wait for characters?
usart_transmit(W_buffer[i]);
}
usart_transmit('#'); //will be send after 8 receives???