I would like to implement serial.write() command in Arduino UNO by using interrupt command of Atmel Atmega328P.
The data of Atmega328P is: http://www.atmel.com/Images/doc8271.pdf
The following is the code I try to write but it seems like it doesn't work.
#include <avr/io.h>
#include <util/delay.h>
#include <avr/interrupt.h>
#define BAUD 9600
void serial_init()
{
uint16_t ubbr;
ubbr = 103;
UBRR0H = ubbr >> 8;
UBRR0L = ubbr & 0xff;
#if 0
UBRR0H = UBRRH_VALUE;
UBRR0L = UBRRL_VALUE;
#endif
UCSR0C = (3 << UCSZ00);
UCSR0B = (1 << RXEN0) | (1 << TXEN0);
UCSR0B = (1<<TXCIE0);
return;
}
char *uart = "abc";
int i=0;
ISR(USART_TXC_vect){
if (i<5)
UDR0=uart[i++];
}
int main(void){
serial_init();
return 0;}
Thanks for your help