Saturday, 28 September 2013

AVR usart communcation with arduino

AVR usart communcation with arduino

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?

No comments:

Post a Comment