#include <util/delay.h>
void init_serial(unsigned char rate)
{
UCSRB = (1<<TXEN)|(1<<RXEN)|(1<<RXCIE); // transmission enable with interrupt
UCSRC = (1<<UCSZ0)|(1<<UCSZ1)|(1<<URSEL);
UBRRL = rate;
}
void uart_print(unsigned char ch) //what ever you want to send serially to the tx pin.
{
while(! (UCSRA & (1<<UDRE)));
UDR = ch;
// _delay_ms(100);
}
void uart_puts (char *s)
{
while (*s) //While *s is not NULL
{
uart_print(*s);
s++;
}
}
void uart_print_delay(unsigned char ch)//, unsigned char pause) //what ever you want to send serially to the tx pin.
{
while(! (UCSRA & (1<<UDRE)));
UDR = ch;
_delay_ms(100);
}
void uart_puts_delay(char *s)//,unsigned char pause)
{
while (*s) //While *s is not NULL
{
uart_print_delay(*s);//, pause);
s++;
}
}
void start()
{
unsigned char str[23] = "\n\r this is how it starts \n";
unsigned char i = 0;
for (i = 0 ; i <= 23 ; i++)
{
uart_print(str[i]);
}
}