Quantcast
Channel: Microcontrollers
Viewing all articles
Browse latest Browse all 4923

Serial communication programming in atmega328p on arduino

$
0
0
I am trying to program arduino's atmega328p serial communication registers myself. After referring to several resources on the internet I have arrived at the following code:

Code (Text):
  1. #define BAUDRATE(BAUD) (((F_CPU/(BAUD*16UL)))-1)
  2.     class serials
  3.     {
  4.               serials()
  5.         {
  6.             UBRR0H = BAUDRATE(9600) >> 8;
  7.             UBRR0L = BAUDRATE(9600);
  8.  
  9.             UCSR0B = _BV(TXEN0) | _BV(RXEN0) | _BV(TXCIE0);
  10.             UCSR0C = _BV(UCSZ01) | _BV(UCSZ00);
  11.         }...
Serial communication programming in atmega328p on arduino

Viewing all articles
Browse latest Browse all 4923

Trending Articles