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:
Serial communication programming in atmega328p on arduino
Code (Text):
- #define BAUDRATE(BAUD) (((F_CPU/(BAUD*16UL)))-1)
- class serials
- {
- serials()
- {
- UBRR0H = BAUDRATE(9600) >> 8;
- UBRR0L = BAUDRATE(9600);
- UCSR0B = _BV(TXEN0) | _BV(RXEN0) | _BV(TXCIE0);
- UCSR0C = _BV(UCSZ01) | _BV(UCSZ00);
- }...