Shop OBEX P1 Docs P2 Docs Learn Events
RFID Issues with MSP430 using the UART interface — Parallax Forums

RFID Issues with MSP430 using the UART interface

wandererwanderer Posts: 2
edited 2009-03-29 05:46 in General Discussion
Hi everyone,

Recently I bought the RFID reader from here but I have been unable to make it work the way i would like to. I'm using UART to connect with the RFID and it looks like I'm able to read information from the tags by using the code below (I get a mix of what I would expect with some random stuff), but I'm not sure on how to receive the whole string of a tag. Any ideas?? Thanks in advance!

#include "msp430x54x.h"


void main(void)
{
 
  WDTCTL = WDTPW + WDTHOLD;

  P10SEL = 0x30;                             // P3.4,5 = USCI_A0 TXD/RXD
  UCA3CTL1 |= UCSWRST;                      // **Put state machine in reset**
  UCA3CTL1 |= UCSSEL_1;                     // CLK = ACLK
  UCA3BR0 = 0x0D;                           // 2400 (see User's Guide)
  UCA3BR1 = 0x00;                           //
  UCA3MCTL |= UCBRS_6+UCBRF_0;              // Modulation UCBRSx=6, UCBRFx=0
  UCA3CTL1 &= ~UCSWRST;                     // lize USCI state machine**
  UCA3IE |= UCRXIE;                         // Enable USCI_A1 RX interrupt
 
  __bis_SR_register(LPM3_bits + GIE);       // Enter LPM3, interrupts enabled
  __no_operation();                         // For debugger
}

// Echo back RXed character, confirm TX buffer is ready first
#pragma vector=USCI_A3_VECTOR
__interrupt void USCI_A3_ISR(void)
{

int i;
char test[noparse][[/noparse]12];
   
    
  switch(__even_in_range(UCA3IV,4))
  {
  case 0:break;                             // Vector 0 - no interrupt
  case 2:                                   // Vector 2 - RXIFG
        
   // USCI_A1 TX buffer ready?
   while (!(UCA3IFG&UCTXIFG));
   
for(i=0; i<13; i++)
    test[i] = UCA3RXBUF;

    //UCA3TXBUF = UCA3RXBUF;                  // TX -> RXed character
  
    break;
  case 4:break;                             // Vector 4 - TXIFG
  default: break;
  }
}

[/i]

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2009-03-28 05:31
    Can't really help you at all with the MSP430 code. The Parallax RFID reader does what the documentation says it does. It occasionally will mis-read the RFID tag as will any RFID reader. This is due to noise or inadequate power to the RFID tag's chip (since the power comes from the RFID reader, it's a bit variable). I did quite a bit of experimenting with the Parallax RFID reader with a Propeller. There wasn't any really random stuff and I could easily read the full RFID id string.

    Make sure your MSP430 UART timing is correct. A timing mismatch will certainly cause random character errors.
  • wandererwanderer Posts: 2
    edited 2009-03-29 05:46
    I have been able to send data through the UART port of the MSP430 from the tags I read, but I believe I am having strong baudrate problems. I am testing with different frequencies to see what can be done. this is my new code :

    #include  <msp430x54x.h>
    
    #include  <stdio.h>
    
    void main(void)
    {
      int temp = 0;
      int hexArray[noparse][[/noparse]12];        //recieved string hex values(ascii)
      char strArr[noparse][[/noparse]12];        //array that will contain actual string
      int i = 0;
      int startByte = 0;
      int stopByte = 0;
     
    
    
     
     
     
      WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT
     
    
      P10SEL = 0x30;                             // P3.4,5 = USCI_A0 TXD/RXD
    
      UCA3CTL1 |= UCSWRST;                      // **Put state machine in reset**
     
    
    
      UCA3CTL0 = 0x20;
    
    
    
      UCA3CTL1 |= UCSSEL_1;                     // CLK = ACLK
    
    
    
      UCA3BR0 = 0x0D;                           // 2400 (see User's Guide)
      UCA3BR1 = 0x00;
    
    
     
    
        UCA3CTL1 &= ~UCSWRST;                     // Initialize USCI state machine**
    
    
        UCA3IE |= UCRXIE;                         // Enable USCI_A1 RX interrupt
    
    // Mainloop
      while (1){
     
    
      __bis_SR_register(LPM3_bits + GIE);       // Enter LPM3, interrupts enabled
    
    
    
       while (!(UCA3IFG&UCTXIFG));               // USCI_A1 TX buffer ready?
       
      temp = UCA3RXBUF;                        // RXBUF0 to TXBUF0
     
     
      if(i<12){
       
        hexArray[i] = temp;     
    
        i+=1;
      }
      if(i>=12)
      {
      
       
        i = 0;
      }
     
     
      }
     
     
    }
    
    
    
    #pragma vector=USCI_A3_VECTOR
    __interrupt void USCI_A3_ISR(void)
    
    {
    
     _BIC_SR_IRQ(LPM3_bits + GIE); //exit low power mode  
    }
    
    [/i]
    




    Any help would really be appreciate it.
Sign In or Register to comment.