RFID Card Reader Serial 28140 UART to MSP430 Help!
Does anyone have any example code for reading from the Parallax RFID Card Reader?
I'm not sure what I'm doing wrong, but I know the baud rate has to be 2400.
I worked off an example msp430 uart code, but I see nothing in the receive buffer.
I'm not sure what I'm doing wrong, but I know the baud rate has to be 2400.
I worked off an example msp430 uart code, but I see nothing in the receive buffer.
#include <msp430.h>
char RxByte;
char RxData[256];
char TxByte;
volatile unsigned int i;
int main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
if (CALBC1_8MHZ==0xFF) // If calibration constant erased
{
while(1); // do not load, trap CPU!!
}
DCOCTL = 0; // Select lowest DCOx and MODx settings
BCSCTL1 = DIVA0;
BCSCTL1 = CALBC1_8MHZ;
DCOCTL = CALDCO_8MHZ; // Load 8MHz constants
P1OUT &= ~0x01; // Clear P1.0
P1DIR |= 0x01; // P1.0 output
P3SEL |= 0x30; // Use P3.4/P3.5 for USCI_A0
UCA0CTL1 |= UCSWRST; // Set SW Reset
UCA0CTL1 = UCSSEL_2 + UCSWRST; // Use SMCLK, keep SW reset
UCA0BR0 = 0x05; // 8MHz/3333=2.4KHz
UCA0BR1 = 0x0D;
UCA0MCTL = UCBRF_1 + UCOS16; // Set 1st stage modulator to 1
// 16-times oversampling mode
UCA0IRTCTL = UCIRTXPL2 + UCIRTXPL0 + UCIRTXCLK + UCIREN;
// Pulse length = 6 half clock cyc
// Enable BITCLK16, IrDA enc/dec
UCA0CTL1 &= ~UCSWRST; // Resume operation
TxByte = 0x00; // TX data and pointer, 8-bit
while (1)
{
for (i = 1000; i; i--); // Small delay
// while (!(IFG2 & UCA0TXIFG)); // USCI_A0 TX buffer ready?
// UCA0TXBUF = TxByte; // TX character
__disable_interrupt();
IE2 |= UCA0RXIE; // Enable RX int
__bis_SR_register(CPUOFF + GIE); // Enter LPM0 w/ interrupts
// RxByte = UCA0RXBUF; // Get RXed character
if (RxByte == 0x0A) // RX OK?
{
RxData[0] = RxByte; // Store RXed character in RAM
P1OUT |= 0x01; // LED P1.0 on
}
if (RxByte == 0x0D) // RX OK?
{
RxData[1] = RxByte; // Store RXed character in RAM
P1OUT |= 0x01; // LED P1.0 on
}
TxByte++; // Next character to TX
}
}
#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector = USCIAB0RX_VECTOR
__interrupt void USCIAB0RX_ISR(void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(USCIAB0RX_VECTOR))) USCIAB0RX_ISR (void)
#else
#error Compiler not supported!
#endif
{
RxByte = UCA0RXBUF; // Get RXed character
IE2 &= ~UCA0RXIE; // Disable RX int
__bic_SR_register_on_exit(CPUOFF); // Exit LPM0
}

Comments