Dear All
Does anyone have any example code for reading from the RFID Card Reader?
I'm not sure what I'm doing wrong, but I know the baud rate has to be 9600.
I worked off an example msp430 uart code, but I see only random number in the receive buffer.
#include <msp430.h>
unsigned int i=0;
char temp[12];
void start_init()
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
P1DIR=BIT0;
if (CALBC1_1MHZ==0xFF) // If calibration constant erased
{
while(1); // do not load, trap CPU!!
}
DCOCTL = 0; // Select lowest DCOx and MODx settings
BCSCTL1 = CALBC1_1MHZ; // Set DCO
DCOCTL = CALDCO_1MHZ;
P1SEL = BIT1 + BIT2 ; // P1.1 = RXD, P1.2=TXD
P1SEL2 = BIT1 + BIT2 ; // P1.1 = RXD, P1.2=TXD
UCA0CTL1 |= UCSSEL_2; // SMCLK
UCA0BR0 = 104; // 1MHz 9600
UCA0BR1 = 0; // 1MHz 9600
UCA0MCTL = UCBRS0; // Modulation UCBRSx = 1
UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
}
unsigned char uart_getc()
{
while (!(IFG2&UCA0RXIFG)); // USCI_A0 RX buffer ready?
return UCA0RXBUF;
}
void uart_putc(unsigned char c)
{
while (!(IFG2&UCA0TXIFG)); // USCI_A0 TX buffer ready?
UCA0TXBUF = c; // TX
}
int main(void)
{
unsigned char b;
start_init();
while(1)
{
b = uart_getc();
uart_putc(b);
}
}
Thanks in advance