I am trying to setup up a basic serial communcation link between an ATMEGA8515 and an Arduino Uno. I am Putty connection to the correct com port I can see the Arudino print "got:got:" in burst of two going with the delay. So the problem is that the Arduino is recognizing that something is being transmitted but not getting any characters.
I've been trying to use the transmit code on page 143 of the datasheet in my main loop:
int main(void)
{
//Baud is 9600
USART_Init(USART_BAUDRATE);
//init interrupt
sei();
DDRA |= _BV(DDA6);
while(1)
{
USART_Transmit("a\n");
_delay_ms(5000);
}
}
And trying to recieve the serial using this code taken from here:
char val; // variable to receive data from the serial port
void setup() {
Serial.begin(9600); // start serial communication at 9600bps
}
void loop() {
if( Serial.available() ) // if data is available to read
{
val = Serial.read(); // read it and store it in 'val'
Serial.print("got:"+val);
}
delay(100); // wait 100ms for next reading
}
This results in "got:" being printed twice every 5 seconds:
I hooked up an LED to the TX line of the AVR and can see when its tranmitting. The TX line of the AVR is hooked into the RX line of the arduino and the same fasion for AVR RX.
Any ideas why I can't see the char that i'm trying to transmit?
One odd thing is that the RX light never blinks on the Arduino making it seem that its not getting anything but the TX always blinks as its printing to the com port.
EDIT: This is the code i'm using for transmit:
void USART_Transmit( unsigned char data )
{
/* Wait for empty transmit buffer */
while ( !( UCSRA & (1<<UDRE)) )
;
/* Put data into buffer, sends the data */
UDR = data;
}
and have changed my main code to USART_Transmit("a");
I also tried Serial.print(val, HEX);
on the arduino which prints 0s.