Communicating with non-arduino AVR over serial
i have arduino mega , wanted dive in , see how works following this tutorial atmega644 , usbasp programmer. after blinking led, felt next logical step communicate bytes on serial connection arduino. unfortunately, regardless of arduino receives random combination of 0 , 128 values.
things i've tried:
this cut down version of program on atmega644 sends bytes, have tried 6 other programs provided in serial communication tutorials no noticeable effect:
arduino sketch:
at point i'm positive i've configured wrong i've exhausted every possibility can think of. shed light on why might receiving random values of either 0 or 128, when change every condition possible in programs? try , simplify trying receive serial data through usb port usbasp sadly doesn't support serial communication avr computer.
thanks in advance
things i've tried:
- reading serial data transmitted atmega644 second serial connection(since have mega), , softwareserial library(on 10 , 11 pins)
- changing baud rate no effect on random 0 , 180 values
- confirmed timing set correctly , 16mhz led flashing program @ 1 second intervals.
this cut down version of program on atmega644 sends bytes, have tried 6 other programs provided in serial communication tutorials no noticeable effect:
code: [select]
#include <stdio.h>
#include <avr/io.h>
#include <util/delay.h>
#define f_cpu 16000000
#define baud 9600
#include <util/setbaud.h>
void uart_init(void) {
ubrr0h = ubrrh_value;
ubrr0l = ubrrl_value;
#if use_2x
ucsr0a |= _bv(u2x0);
#else
ucsr0a &= ~(_bv(u2x0));
#endif
ucsr0c = _bv(ucsz01) | _bv(ucsz00);
ucsr0b = _bv(rxen0) | _bv(txen0);
}
void uart_putchar(char c) {
loop_until_bit_is_set(ucsr0a, udre0);
udr0 = c;
}
int main(void) {
uart_init();
for(;;;)
uart_putchar('a');//i've tried sending incremental values try , affect random output
return 0;
}
arduino sketch:
code: [select]
#include <softwareserial.h>
softwareserial portone(10,11);
void setup()
{
serial.begin(9600);
portone.begin(9600);
}
void loop()
{
portone.listen();
while (portone.available() > 0) {
serial.println("data port one:");
unsigned char inbyte = portone.read();
serial.print(inbyte);
serial.println();
}
}
at point i'm positive i've configured wrong i've exhausted every possibility can think of. shed light on why might receiving random values of either 0 or 128, when change every condition possible in programs? try , simplify trying receive serial data through usb port usbasp sadly doesn't support serial communication avr computer.
thanks in advance

code: [select]
softwareserial portone(10,11,true);why configuring inverted signals? give strange results. lose "true" part unless have reason.
Arduino Forum > Using Arduino > Microcontrollers > Communicating with non-arduino AVR over serial
arduino
Comments
Post a Comment