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.

MSP430F2370: custom NFC board with TRF7970A

Part Number: MSP430F2370
Other Parts Discussed in Thread: TRF7970A,

Hi,

I have a custom board based on MSP430F2370 and TRF7970A. The design is based on TI's TRF7970AEVM http://www.ti.com/tool/trf7970aevm

I'm using the TI's code example for the TRF7970AEVM http://www.ti.com/general/docs/lit/getliterature.tsp?baseLiteratureNumber=sloc300&fileType=zip

I flashed the software but it is getting stuck at a point.

main.c Iso14443aFindTag() -> Trf797xTurnRfOn() -> Trf797xReadSingle() -> SpiReadSingle() at while(UCB0STAT & UCBUSY)

Please help me on finding the root cause

  • Hello Madhu,

    I'm going to move this over to the E2E that supports NFC.  

    Thanks,

    JD

  • Hello Madhu,

    The TRF7970AEVM is obsoleted and the software for it is not supported as it had many glitches.

    I recommend porting this software to your board, it will run well on that MCU and has been heavily updated and tested so it is robust: www.ti.com/.../sloc297

  • Hi Ralph,

    Thanks for the suggestion. I started porting and changed the www.ti.com/.../sloc297 to work with msp430f2370 and got stuck at a point, in my custom board the XIN pin of msp430f2370 is connected to the SYS_CLK of TRF7970A.

    I'm new to MSP's so what change I have to do to the www.ti.com/.../sloc297 to work with my board ? I want to know what changes to be done to the mcu clock init ?

    Regards,

    Madhusudhan

  • Hello Madhusudhan,

    You'd have to make sure the SYS_CLK output is being configured properly.

    Everywhere in the trf79xxa.c file where TRF79XXA_MODULATOR_CONTROL is written, you will want to OR the byte with 0x30 (presuming you are using a 13.56 MHz crystal, otherwise 0x20 if using a 27.12 MHz crystal) in order to enable the SYS_CLK output.

    Sorry that the comments in TRF79xxA_setupInitiator state that the SYS_CLK is being output as those are wrong, the SYS_CLK is not output by default.


  • Hi Ralph,

    I have made the changes you have mentioned and also the changes below, now I'm able to detect the nfc tags but unable to read them.

    main.c

    void main(void)
    {
    //uint8_t ui8VLOCalibCount;

    // TODO: Remove LED2 Jumper on G2 LaunchPad if using it, otherwise SPI will not work.

    // Stop the Watchdog timer,
    WDTCTL = WDTPW + WDTHOLD;

    MCU_initClock(0); // Set DCO
    MCU_delayMillisecond(10);

    // Calibrate VLO
    //MCU_calculateVLOFreq();

    // Set the SPI SS high
    SLAVE_SELECT_PORT_SET;
    SLAVE_SELECT_HIGH;

    // Four millisecond delay between bringing SS high and then EN high per TRF7970A Datasheet
    MCU_delayMillisecond(4);

    // Set TRF Enable Pin high
    TRF_ENABLE_SET;
    TRF_ENABLE;

    // Wait until TRF system clock started
    MCU_delayMillisecond(5);

    // Set up TRF initial settings
    TRF79xxA_initialSettings();
    TRF79xxA_setTrfPowerSetting(TRF79xxA_3V_FULL_POWER);

    MCU_initClock(1); // Switching from DCO to external clock
    MCU_delayMillisecond(10);
    SPI_usciSet(); // Re-configure the USART with this external clock

    // Initialize all enabled technology layers
    NFC_init();

    // Enable global interrupts
    __bis_SR_register(GIE);

    // Enable IRQ Pin
    IRQ_ON;

    while(1)
    {
    // Poll for NFC tags
    NFC_findTag();
    /*ui8VLOCalibCount++; 

    if (ui8VLOCalibCount == 25)
    {
    // Calibrate VLO
    MCU_calculateVLOFreq();
    // Reset Calibration Counter
    ui8VLOCalibCount = 0;
    }*/
    }
    }

    mcu.c

    void MCU_initClock(uint8_t mode)
    {
    uint8_t ii1 = 0;

    if(mode == 0)
    {
    // select DCO to 8MHz

    if (CALBC1_8MHZ==0xFF) // If calibration constant erased
    {
    while(1); // do not load, trap CPU!!
    }

    // Follow recommended flow. First, clear all DCOx and MODx bits.
    // Then apply new RSELx values. Finally, apply new DCOx and MODx bit
    // values.
    DCOCTL = 0x00;
    BCSCTL1 = CALBC1_8MHZ;
    DCOCTL = CALDCO_8MHZ;

    __delay_cycles(1000);

    return;
    }
    else
    {
    BCSCTL1 |= XTS + XT2OFF; // ACLK = LFXT1 HF XTAL
    BCSCTL3 |= LFXT1S1; // 3 – 16MHz crystal or resonator
    // the TRF796x sys_clk pin works as ocillator
    // it is set to 6.78 MHz (= 13.56 MHz / 2) in Trf797xInitialSettings()
    // turn external oscillator on
    do
    {
    IFG1 &= ~OFIFG; // Clear OSCFault flag
    for (ii1 = 0xFF; ii1 > 0; ii1--) // Time delay for flag to set
    {
    }
    } while ((IFG1 & OFIFG) == OFIFG); // OSCFault flag still set?

    BCSCTL2 |= SELM1 + SELM0 + SELS; // MCLK = SMCLK = HF LFXT1 (safe)

    return;
    }
    }


    #define COUNTER_VALUE TACCR0 //counter register
    #define START_COUNTER TACTL |= MC1 //start counter in up mode
    #define STOP_COUNTER TACTL &= ~(MC0 + MC1) //stops the counter
    #define RESET_COUNTER TACTL |= TACLR //Resets and stops counter.

    #define DELAY_1ms 6780 // Used for McuDelayMillisecond

    #define COUNT_1ms 847

    void MCU_setCounter(uint16_t ui16mSecTimeout)
    {
          TACTL |= TACLR;
          TACTL &= ~TACLR; // reset the timerA
          TACTL |= TASSEL0 + ID1 + ID0; // ACLK, div 8, interrupt enable, timer stoped

          TAR = 0x0000;
          TACCTL0 |= CCIE; // compare interrupt enable
          COUNTER_VALUE = COUNT_1ms * ui16mSecTimeout;
          TACTL |= MC1;
    }

    #pragma vector=TIMERA0_VECTOR
    __interrupt void
    Msp430f23x0TimerAHandler(void)
    {
          TRF79xxA_timerHandler();
    }

  • Hi Ralph,

    Finally I got it working, there was an optimization issue.

    Please check the above code and let me know if I have to change anything else.

    Regards,

    Madhusudhan

  • Hello Madhusudhan,

    Nothing sticks out to me at first glance, and if it's working I imagine you got everything, the code needs pretty much everything firing on all cylinders to work well.

    You may want to check if the VLO calibration is required, I don't know how much the VLO drifts on the MSP430F2370, but if it's a good amount then you probably will want it.

  • Hi Ralph,

    If you check my code I'm not using VLO at all, Is that fine ?

    Also I have designed the card sensing circuit and want to know how to use that ? If you want I can send schematics in private.

    Regards,

    Madhusudhan

     

  • Hello Madhusudhan,

    The VLO wouldn't be something you'd notice in 10 minutes, but drift over time could impact long term operation. Just something to look into from a system standpoint.

    I had done some work but ultimately never finished getting the card sensing circuit software to work with the SLOC297 example, that is not something we are supporting at this time from a debug level. The app note has all the details and implementation is up to you: http://www.ti.com/lit/an/sloa184/sloa184.pdf

  • Hi Ralph,

    Sorry for this question after a long delay.

    I got into a strange issue. When I try to send data in UART after detecting the card in iso14443a.c, I'm getting junk data at the receiving side. But when I try to send UART data in main.c after calling the NFC_findTag() function the data is going properly that too if I give a delay of atleast 1 millisec for every byte I send in UART like below. Please help me in finding the problem

    for (i=0; i<20; i++)
    {
    UART_putChar(uartTxBuf[i]);
    MCU_delayMillisecond(1);
    }

    Regards,

    Madhusudhan

  • Hello Madhusudhan,

    Check your baud rate configuration for your terminal, it should be set to 9600. I did a quick test with a ported version of the code and it worked fine to output data as long as the terminal is set to 9600 baud.

  • Hi Ralph,

    I'm using the UART for LIN. So I assume the issue is related to LIN. Do you have any example code for LIN protocol ?

    Also I got into one more issue. The TRF7970A is powered at 5V, when I set the TRF79xxA_setTrfPowerSetting to TRF79xxA_3V_FULL_POWER the board is working fine but when I set it to TRF79xxA_5V_FULL_POWER the board is going bad and I'm unable to flash anymore and I had to change the chips. I don't know why the MSP430F2370 is going bad when I change the TRF79xxA_setTrfPowerSetting of TRF7970A. Please help me with this.

    Regards,

    Madhusudhan

  • Hello Madhusudhan,

    I can't help with LIN, you may need to make a new thread for that.

    I've never heard of the TRF7970A causing a failure in the MCU due to being in 5V mode. Did you source VDD_IO with VIN? VDD_X would not exceed 3.4V which is within the 3.6V VCC maximum limit for the MSP430F2370. It sounds like that may be a system or schematic issue.

  • Hi Ralph,

    I can send my schematics to you personally. Can you please help me in finding the root cause ? I'm using the TRF7970A for the first time.

    Regards,

    Madhusudhan

  • Hello Madhusudhan,

    I sent you a friend request, you can send it to me via Private Message once you accept.

**Attention** This is a public forum