i am trying to interface RFID reader with atmega16. The RFID reader i am using is **broken link removed** - baud rate 9600 & i am using ttl output from Tx pin. i hv used a 12Mhz oscillator on development board.
i am using the following code in eclipse. when the card is read i am getting some garbage characters like pi, delta, box or so.. plz help me get the correct tag id on lcd..
#include <avr/io.h>
#include <util/delay.h>
#include "lcd_lib.h"
#define F_CPU 12000000UL
#define USART_BAUDRATE 9600
#define BAUD_PRESCALE (((F_CPU / (USART_BAUDRATE *16UL)))- 1)
int main (void)
{
LCDinit();
LCDclr();
_delay_ms(50);
char ReceivedByte;
UCSRB |= (1 << RXEN) | (1 << TXEN);
//enable transmission and reception
UCSRC |= (1 << URSEL) | (1 << UCSZ0) | (1 << UCSZ1); //Use 8-bit character size
UBRRH = (BAUD_PRESCALE >> 8);
// Load upper 8-bits of the baud rate value
UBRRL = BAUD_PRESCALE;
// Load lower 8-bits of the baud rate value
LCDGotoXY(1,0);
for (;
// Loop forever
{
while ((UCSRA & (1 << RXC)) == 0) {};
// Do nothing until data have been received
ReceivedByte = UDR;
// Fetch the received byte value
LCDdisplay(ReceivedByte);
_delay_ms(300);
}
}