I'm using Atmega 324p to send each second the character '0' to Arduino but instead it receives this:
Sofware used:
Atmel 7
Arduino 1.8.9
Arvdudess 2.11
Atmel code:
#include "avr/io.h"
#include "util/delay.h"
#define FOSC 1500000 //Clock speed
#define BAUD 9600
#define MYUBRR (FOSC/(16*BAUD-1))
void USART_Init(unsigned int ubrr){
/*Set baud rate /
UBRR0H = (unsigned char)(ubrr>>8 );
UBRR0L = (unsigned char)ubrr;
/ Enable receiver and transmitter /
UCSR0B = (1<<RXEN0)|(1<<TXEN0);
/ Set frame format: 8data, 2stop bit */
UCSR0C = (1<<USBS0)|(3<<UCSZ00);
}
void USART_Transmit( unsigned char data ){
/* Wait for empty transmit buffer /
//while ( !( UCSR0A & (1<<UDRE)) );
/ Put data into buffer, sends the data */
UDR0 = data;
}
int main(void)
{
USART_Init(MYUBRR);
/* Replace with your application code */
while (1)
{
USART_Transmit('0');
_delay_ms(1000);
}
Arduino code:
char received_data; //variable to store read data
void setup() {
Serial.begin(9600);
}
void loop() {
if(Serial.available()>0) //check for any data received
{
Serial.print("Char :");
received_data = Serial.read(); //read received data
Serial.println(received_data); //display received data
}
}
Arvdudess config:
Rougth circuit sketch: