cancel
Showing results for 
Search instead for 
Did you mean: 

Error in transplant the st25r3911b device

LevenTao
Associate

Recently, I am working on a project. I need to use the nrf52832 driver st25r3911b chip to read the card. The current progress is that I can use the st25r3911 driver to initialize, and the initialization has been successful, but it seems that there is no response to the nfcv card. Then I compared the situation of using the development board and found that the st25r3911 did not generate interruption during operation, (When I use the stm32L476 development board to drive the NFC05A1 development board, I can see that the interrupt pin of the NFC05A1 always generates interrupt signals), but I don't know what causes this. Since I have just started this chip, the code used is basically the same as demo's code. What I want to know is, what should I pay attention to when porting the st25r3911b sdk? There is also the reason that may lead to the above problem. I hope someone can give me a solution. Thank you very much.

Below is part of the code

 

 

void spi_event_handler(nrf_drv_spi_evt_t const *p_event, void *p_context)
{
    spi_xfer_done = true;
}

static void hal_spi_init(void)
{
    nrf_drv_spi_config_t spi_config = NRF_DRV_SPI_DEFAULT_CONFIG;
    spi_config.ss_pin = SPIM0_SS_PIN;
    spi_config.miso_pin = SPIM0_MISO_PIN;
    spi_config.mosi_pin = SPIM0_MOSI_PIN;
    spi_config.sck_pin = SPIM0_SCK_PIN;
    spi_config.mode = NRF_DRV_SPI_MODE_1;
    spi_config.frequency = NRF_DRV_SPI_FREQ_2M;
    APP_ERROR_CHECK(nrf_drv_spi_init(&m_spi, &spi_config, spi_event_handler, NULL));
}

uint8_t nrf_spi_tx_rx(const uint8_t *txData, uint8_t *rxData, uint8_t len)
{
    if (txData != NULL)
    {
        memcpy(tx, txData, len);
    }
    else
    {
        memset(tx, 0x00, len);
    }
    spi_xfer_done = false;
    APP_ERROR_CHECK(nrf_drv_spi_transfer(&m_spi, tx, len, (rxData != NULL) ? rxData : rx, len));
    while (!spi_xfer_done)
    {
        __WFE();
    }
    nrf_delay_ms(1);
    return 0;
}

int main(void)
{
    bool erase_bonds;

    // Initialize.
    log_init();
    timers_init();
    lfclk_config();
    rtc_config();
    hal_spi_init();
    gpio_init();
    buttons_leds_init(&erase_bonds);
    power_management_init();
    ble_stack_init();
    gap_params_init();
    gatt_init();
    advertising_init();
    services_init();
    conn_params_init();
    peer_manager_init();

    // Start execution.
    NRF_LOG_INFO("miaomiao3 device started.");
    application_timers_start();

    advertising_start(erase_bonds);

    rfalAnalogConfigInitialize();
    if (rfalInitialize() != ERR_NONE)
    {
        platformLog("RFAL initialization failed..\r\n");
    }
    else
    {
        platformLog("RFAL initialization succeeded..\r\n");
    }

    // Enter main loop.
    for (;;)
    {
        idle_state_handle();
        rfalWorker();
        workCycle();
    }
}

void workCycle(void)
{
    bool found = false;

    switch (stateArray[state])
    {
    case FIELD_OFF:
        rfalFieldOff();
        rfalWakeUpModeStop();
        platformDelay(300);

        /* If WakeUp is to be executed, enable Wake-Up mode */
        if (doWakeUp)
        {
            platformLog("Going to Wakeup mode.\r\n");

            rfalWakeUpModeStart(NULL);
            state = WAIT_WAKEUP;
            break;
        }

        NEXT_STATE();
        break;

    case POLL_ACTIVE_TECH:
        demoPollAP2P();
        platformDelay(40);
        NEXT_STATE();
        break;

    case POLL_PASSIV_TECH:
        found |= PollNFCV();

        platformDelay(300);
        state = FIELD_OFF;
        break;

    case WAIT_WAKEUP:

        /* Check if Wake-Up Mode has been awaked */
        if (rfalWakeUpModeHasWoke())
        {
            platformLog("start poll\r\n");
            /* If awake, go directly to Poll */
            rfalWakeUpModeStop();
            state = POLL_ACTIVE_TECH;
        }
        break;

    default:
        break;
    }
}

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

Hi,

I would suggest to connect a logic analyzer on the SPI (CLK/MOSI/MISO/CS) + ST25R3911_IRQ on your custom board and share the trace with the issue you have mentioned.

Rgds

BT

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

View solution in original post

3 REPLIES 3
Brian TIDAL
ST Employee

Hi,

I would suggest to enable the ST25R_SELFTEST compilation switch: this adds extra checks during the initialization of the ST25R3911B, in particular this checks that the interrupt line is working (see st25r3911Initialize function). 

I suggest also to check that the MCU GPIO pin connected to the ST25R3911B IRQ line is properly configured (e.g. there should be no pull down).

When an interrupt is triggered from the ST25R3911B, the Interrupt Service Routine shall call the st25r3911Isr() function to read the ST25R3911B interrupt status registers. Make sure to protect the SPI communication channel (see the platformProtectST25RComm macros in the platform.h to provide exclusive access to the SPI communication between the ISR and the worker task).

Rgds

BT

 

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
LevenTao
Associate

Hi,

Thank you for reply.

There should be no problem with the interrupted connection, then I will try the function of opening the selftest as you said.

and then I just found a phenomenon today. I added codes to read all register data of the st25r3911b after the initialization of the development board and my own equipment respectively, and then found that the data in the register after the initialization of my equipment is basically consistent with the default state after power-on in the manual, does this mean that the configured code is not working?

The other is that st25r3911ReadMultipleRegisters() doesn't seem to work, returning only one bit of valid data.

I will continue to update my progress, thank you again for your reply.

Hi,

I would suggest to connect a logic analyzer on the SPI (CLK/MOSI/MISO/CS) + ST25R3911_IRQ on your custom board and share the trace with the issue you have mentioned.

Rgds

BT

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.