MSP430F6779A: TRF7970a

Part Number: MSP430F6779A
Other Parts Discussed in Thread: TRF7970A

Tool/software:

Hi there ,
I'm currently working with the NFC functionality , and I am facing an issue with the NFC_run() function. the example code is used for MSP430f5529LP kit and I'm using the MSp430F6779a Microcontroller and trying to integrating the TRF7970a RFID.

When I run the following code:

// States for all NFC protocol state machines
typedef enum {
NFC_STATE_IDLE = 0,
NFC_TARGET_WAIT_FOR_ACTIVATION,
NFC_PROTOCOL_ACTIVATION,
NFC_PARAMETER_SELECTION,
NFC_DATA_EXCHANGE_PROTOCOL,
NFC_MIFARE_DATA_EXCHANGE_PROTOCOL,
NFC_DEACTIVATION,
NFC_DISABLED
} tNfcState;

////////First step /////////////////////////************inside main function*********////////////////////////////////////////////////////////

eTempNFCState = NFC_run();
if (eTempNFCState == NFC_DATA_EXCHANGE_PROTOCOL)
{
 if (NFC_RW_getModeStatus(&sRWMode, &sRWBitrate))
    {
          // Some operations here
    }
}
//////////////////second step **********  inside the NFC_run() ************ ////////////////////////////////////////////////////

else if(g_sNfcStatus.sNfcModeCurrent.bits.bNfcModePoll == 1)
{
sReturnNfcState = NFC_pollStateMachine();
}

////////////////////////// **************third step **********inside pollstateMcahine () *********************

tNfcState NFC_pollStateMachine(void)
{
#if (NFC_PEER_2_PEER_INITIATOR_ENABLED || NFC_READER_WRITER_ENABLED)
tTRF79x0_IRQFlag eTrfIrqStatus = IRQ_STATUS_IDLE;
tTRF79x0_Status sTRF79x0Status;
tNfcInitiatorState eInitiatorState;
uint16_t ui16PICCTimeOut = 0;

t_sTRF79x0_InitiatorMode sTRFInitMode;
t_sTRF79x0_Bitrate sTRFBitrate;

#if (NFC_P2P_PASSIVE_INIT_ENABLED || NFC_READER_WRITER_ENABLED)
bool bPassiveRfField = false;
uint8_t ui8Status;
#endif

bool bISODep = false;
bool bNFCADep = false;
bool bNFCFDep = false;

switch(g_sNfcStatus.eNfcState)
{
case NFC_PROTOCOL_ACTIVATION:

case NFC_PROTOCOL_ACTIVATION:
// Initialize all current mode variables
g_sNfcStatus.sRWModeCurrent.ui8byte = 0x00;
g_sNfcStatus.sRWCommCurrent.ui16byte = 0x0000;
g_sNfcStatus.sP2PModeCurrent.ui8byte = 0x00;
g_sNfcStatus.sP2PCommCurrent.ui8byte = 0x00;

// Initialize all NFC layers to default values
NFC_Initiator_Init();

// Set DEP Support for ISO DEP and NFC DEP
#if (NFC_READER_WRITER_ENABLED)
if (g_sNfcStatus.sRWModeSupport.bits.bNfcA == 1
|| g_sNfcStatus.sRWModeSupport.bits.bNfcB == 1)
{
bISODep = true;
}
#endif

#if (NFC_RW_T5T_ENABLED)
// Check for NFC-V Technology Activation
if( (g_sNfcStatus.eNfcState == NFC_PROTOCOL_ACTIVATION) &&
(g_sNfcStatus.sRWModeSupport.bits.bISO15693 == 1) &&
(g_sNfcStatus.sRWCommSupport.bits.bISO15693_26_48kbps == 1))
{
// Reset Modes
sTRFInitMode.ui8byte = 0X00;
sTRFBitrate.ui16word = 0X0000;
sTRFInitMode.bits.bPassive15693 = 1;

TRF79x0_setNfcMode(false);

if(g_sNfcStatus.sRWCommSupport.bits.bISO15693_26_48kbps == 1)
{
sTRFBitrate.bits.b26_48_kbps_1_out_4 = 1;
}
else
{
// For other possible 15693 bitrates
}

// Check if the RF field has been already enabled
if(bPassiveRfField == false)
{
ui8Status = TRF79x0_initiatorModeSetup(sTRFInitMode,sTRFBitrate);
bPassiveRfField = true;
}
else
{
ui8Status = TRF79x0_switchInitiatorBaudRate(sTRFInitMode,sTRFBitrate,true);
}

if(ui8Status == STATUS_SUCCESS)
{
if(g_bSupportCertification == true)
{
// Delay Guard Time - 5 mSec ( spec requires 5 milliseconds)
MCU_delayMillisecond(5);
}
else
{
// Delay Guard Time - 10 mSec to power RF430FRL RF Powered Reference Design
MCU_delayMillisecond(10);
}

NFC_Initiator_StateMachine(sTRFInitMode);

ui16PICCTimeOut = NFC_Initiator_GetPICCTimeOut();

eTrfIrqStatus = NFC_waitForCommand(ui16PICCTimeOut);

if(eTrfIrqStatus == IRQ_STATUS_RX_COMPLETE)
{
sTRF79x0Status = TRF79x0_getStatus();

eInitiatorState = NFC_Initiator_ProccessResponse(g_pui8RxData,sTRF79x0Status.ui8FifoBytesReceived,sTRF79x0Status.sInitiatorMode);

if(eInitiatorState == NFC_INITIATOR_TYPE_V_DEP)
{
g_sNfcStatus.eNfcState = NFC_DATA_EXCHANGE_PROTOCOL;

g_sNfcStatus.sRWModeCurrent.bits.bISO15693 = 1;

g_sNfcStatus.sRWCommCurrent.bits.bISO15693_26_48kbps = 1;
}
}
}

}
#endif

return g_sNfcStatus.eNfcState;
}

                             

I expect eTempNFCState to be NFC_DATA_EXCHANGE_PROTOCOL, but instead, it is returning NFC_PROTOCOL_ACTIVATION
it will should return ,

if(eTempNFCState == NFC_DATA_EXCHANGE_PROTOCOL)
{
if(NFC_RW_getModeStatus(&sRWMode,&sRWBitrate))
{
#if NFC_READER_WRITER_ENABLED
NFC_RW_LED_POUT |= NFC_RW_LED_BIT;

if( sRWMode.bits.bNfcA == 1)
{
if(NFC_A_getSAK() == 0x00)
{
// T2T Tag State Machine
T2T_stateMachine();


it wil be eTempNFCState == NFC_DATA_EXCHANGE_PROTOCOL == 4;
but it is returning eTempNFCState == NFC_PROTOCOL_ACTIVATION,== 2; 


Could you please help to resolve this issue .
 

  • Hi, 

    Based on the code you provided above, it may take a lot of time to reproduce your problem. To save your time, I strongly recommend you to try debugging your code by doing single step through your program, and observe the relevant register to see if there is a abnormal state that does not match your expectations, this will help you locate code problems more quickly.

    Best Regards,

    Peter

**Attention** This is a public forum