This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

RFID Card Reader UART to MSP430g2553

Other Parts Discussed in Thread: MSP430F249

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

  • jar raj said:
    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.

     Hi your request as too many coming to these forum is unsolvable so remain without response.

     What kind of card reader are you using? RFID or card reader?

     How about protocol what is from data sheet of device?

     Is RFID reader MSP based?

     This forum is dedicated to MSP430, please post only MSP related request, no job done for free.

  • Thanks for your response.

    What kind of card reader are you using? RFID or card reader?
    I am using 125khz RFID Reader(entesla.com/RFID-READER-125KHZ)

    How about protocol what is from data sheet of device?
    uart protocol only.same RFID reader device i had done with at89c51, now i switch to msp430g2

    it showing only numbers in the tag id

    For ex tag id is :4C001A5D76K9

    it reads only 015769

    Is RFID reader MSP based?
    No

    Thanks in advance

    RAJ M
  • jar raj said:
    it showing only numbers in the tag id

    For ex tag id is :4C001A5D76K9

    it reads only 015769

     So your code get one char and lose one .. why?

     Is correct your approach?

     Why everyone reading from serial use a circular buffer and interrupt?

     Hint try think about how much time the function need and what happen to transmitting side...

  • First thing I noticed is that the reader uses 4.5 to 5.5V supply. If this voltage is used for the TTL output, then it is too high for the MSP and stressing (eventually frying) the MSP port. The note on the datasheet about 5V tolerant RX pins indicates that this is a problem. Except for a few dedicated MSPs, MSP pins are NOT 5V tolerant and an external circuitry is required (a 4k7 series resistor is sufficient).

    I actually don't see a (code) timing problem here. Since RX and TX work with the same baudrate, TXBUF should have had the time to be sent when the next byte has arrived. In theory, the reader could send a bit faster than expected but this wouldn't cause an overflow every second byte.
    It may be that the baudrates are so far off that the MSP detects a framing error for many of the incoming bytes and discards them.
    After all, the DCO doesn't (cannot) deliver steady exact 1MHz, even with the calibration values. There is always some error and some jitter. A different MSP (same model) may work better. For reliable baudrate generation, a crystal should be used.
    It may even be that the reader itself is injecting so much noise into the line (after all, it is a high-power LF transmitter) that the communication fails. Depends on the wiring. (in my own RF-related project, the antenna was injecting so much noise into other signal lines that I couldn't get any reliable readings from a different part, which was a low-impedance analog signal source.

    But it is also possible that the final receiver (where do the bytes you got form the reader and put into TXBUF finally go?) filters non-numeric data from the stream (including multiple leading zeros).

    Nevertheless, the sample ID you posted is weird. IDs are usually numbers. The may be HEX or decimal (depends on how the reader reports them), but they are numbers. The 'K' looks suspicious. Or does the reader submit more than just the ID (but also extended data)?
  • I am reading RFID tags from UART which is coming as 0088585DFF but the serail number printed on the tag is 0008935517 136 22621.
    I don't have any idea why number received in UART buffer is different.

    Kindly help me on this.

    I am using MSP430F249 and RFID reader is of 5V
  • Unfortunately, RFID isn't straight. The different bits in the hex value belong to different 'fields', and it appears that the printed 'serial number' is a sequence of these fields rahte rthan a translation of the hex values.
    IIRC, "136" is the country marker, probably the '88' in the hex string. '585d' is the '22621' part. While the first '0008935517' probably is the manufacturer and RFID type key. YOur reader will filter this and report it by a different command or not at all.
    I had similar problems when I was working on my 'pig scales and bio impedance analysis' project (official name: ConditWatch).
    Take a deep dive into the RFID specification and the reader programming manual (if available), not just the users manual. Maybe you need to contact the manufacturer to get the required information.
  • Thankyou for your notice.

    And what is FF meant which trails 0088585D ?
  • Sorry, I don't have any clue.
    The problem with RFID is that there is no real standard.
    The term 'RFID' simply means that somehow some information of some kind is read from a tag through RF.
    There are quite a few different frequencies with different physical ways to transfer the information. Each pair has its own 'standard' of what information is transmitted and what it means.
    The reader I use supports the HDX ISO, HDX industrial and FDX-B ISO REFID tag type. For the three, the reader output (formatted) reads as
    LA 982 000001088420
    LR 0006 0000000018514243
    LA 982 000001088420
    Where LA means 'line mode - animal coded read only tag' and '982' is the AllFlex manufacturer ID.
    The 'LR' means 'line mode - industrial coded read-only tag' where '0006' is the AllFlex manufacturer ID.
    These outputs do not contain the reserved field and data block bits, the country code bits and other information.
    The reader output can be configured to incliude them. The plain serial number can be 13 or 10 hex digits for the tags I use. And can have duplicates for different countries or manufacturers.
    And this is only for the 134kHz animal tags supported by my reader. There are many more non-ISO sytems, especially outside Europe.
    For other RFID systems, such as the 125kHz tags used for tagging goods, there are other 'standards' with other fields, different data sizes and different meanings. Well, the 125kHz RFID stuff is closest to a standard, as it was the first and the original inventor was copied often. For all other RFID systems, everyone ha sinvented its own system , just to avoid royalties or keep others from entering his market.

    After quite some time of research I figured-out that it is next to impossible to develop an universal panel reader, even if limited just to one of the many different frequencies. The simplest thing would be the 125kHz segment. But the 134kHz animal tags are too many and too different to support them all. I doubt there is a single commercial reader that supports all of them physically. And then interpreting the output is a more than huge task too.
    You better focus on one or two tag types you want to support and go for them, ignoring the remaining.
  • And, well, for the exact meaning of the reader output, consult the reader manual. Ask the manufacturer for detail information - I had lots of trouble with this too, until I found someone who did support me on the maufacturer side. Usually, the readers are just meant to be combined with a display or other stuff from the same manufacturer. At least in the animal tagging market.

**Attention** This is a public forum