Sunday 3 August 2014

avr - ATmega168: UART 8 data bits, no parity, 1 stop bit


According to the datasheet I'm setting the UCSR0C register as following:


UCSR0C = 0b00000110


Description:


Bit   0:   0: TX rising, RX falling
Bit 2-1: 11: character size 8 bit
Bit 3: 0: 1 stop bit
Bit 5-4: 00: no parity
Bit 7-6: 00: asynchronous USART

(http://www.atmel.com/images/doc2545.pdf page 193)


Although I configured the UART to use 8 bit data mode I have to set my communicating terminal (picocom) to use 7 bit data mode. Otherwise I don't get correct data from my ATmega168. I also tried to use minicom and miniterm.py.


My target device I want to communicate with is a Raspberry Pi. I'm using Peter Fleury's UART library (http://homepage.hispeed.ch/peterfleury/group__pfleury__uart.html).



Any ideas what I'm be doing wrong? Did I forget something?



Answer



I solved the problem by using an external oscillator. It seems that the internal oscillator is too imprecise for UART communication.


No comments:

Post a Comment

arduino - Can I use TI's cc2541 BLE as micro controller to perform operations/ processing instead of ATmega328P AU to save cost?

I am using arduino pro mini (which contains Atmega328p AU ) along with cc2541(HM-10) to process and transfer data over BLE to smartphone. I...