This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

nordic nrf51822(SDK10) 0xAA Character clocked out in case of an ignored transaction

Hi ,

I configured nordic as slave and it looks like the transactions been successful, but when 2 SPI transactions occurs consecutively slave was setting 0xAA in return to master transaction.  

The time period between 2 consecutive transaction varies between 5 to 20ms. Can you please let know what can cause this behavior?

Thank you,

    Raj

Parents
  • Hi Raj

    What have you configured the DEF (default) character to be in the SPIS interface?

    Assuming DEF is set to 0xAA it sounds like you are not re-configuring the TX and RX pointers fast enough after a transaction is completed, so that the SPIS interface is unable to acquire the semaphore as described in chapter 27.4 of the nRF51_Series_Reference_Manual

    Are you running a Bluetooth SoftDevice in your application?

    Are there any other modules that could be interrupting the system, delaying the processing of SPIS transactions?

    Best regards
    Torbjørn

  • Hi Torbjørn,

    Yes, I am using the DEF as 0xAA; I am using UART and soft device; I was able to fix this 0xAA issue by just adding delay between 2 consecutively spi transactions from master, But now I am facing different issue looks like the RX buffer is not updating the values fast enough:

    when I logged the TX data it shows [0x80 0x00]; but the logic analyzer shows [0x00 0x00]; Is this caused due to delay in updating the TX pointer? do you have any suggestions. 

    Thank you,

        Raj

  • Hi Raj

    Are you sure the buffers are set correctly, and the semaphore released after?

    Maybe you can share the code you use to configure the SPI slave in between transaction?

    Best regards
    Torbjørn

Reply Children
  • Hi Torbjørn,

    How can I verify if the semaphore released after transfer?

    Here is the SPI configuration code:

    Here is the SPI event handler code:

    static void spi_slave_event_handle(nrf_drv_spis_event_t event)
    {
    uint32_t err_code;

    if (event.evt_type == NRF_DRV_SPIS_XFER_DONE)
    {

    NRF_LOG_PRINTF("event handler rx buffer size is event.rx_amount = %d \n\r",event.rx_amount); 


    if(m_conn_handle == BLE_CONN_HANDLE_INVALID && event.rx_amount!=3){
    build_set_value_4byte_message(ESP32_Communication, 0x5A, ESP_4byte_buffer);
    write_buffer(ESP_4byte_buffer, sizeof(ESP_4byte_buffer));
    }

    nrf_delay_ms(100);

    spi_slave_buffer_command_check(m_rx_buf,m_tx_buf,event.rx_amount,event.tx_amount);
    err_code = nrf_drv_spis_buffers_set(&m_spis, m_tx_buf, sizeof(m_tx_buf), m_rx_buf, sizeof(m_rx_buf));
    APP_ERROR_CHECK(err_code);

    nrf_delay_ms(100);
    if(m_conn_handle == BLE_CONN_HANDLE_INVALID && event.rx_amount!=3){
    build_set_value_4byte_message(ESP32_Communication, 0xA5, ESP_4byte_buffer);
    write_buffer(ESP_4byte_buffer, sizeof(ESP_4byte_buffer));
    }

    }

    }

    Please let me know your suggestions.

    Thank you,

         Raj

    Thank you,

       Raj

  • Hi Raj

    Once the NRF_DRV_SPIS_XFER_DONE event occurs the semaphore should be released to the application, allowing you to reconfigure the buffers. 

    Once this happens you should run the nrf_drv_spis_buffers_set(..) command as quickly as possible to configure new buffers, and return the semaphore to the SPIS peripheral.

    After you have run this command you will receive the NRF_DRV_SPIS_BUFFERS_SET_DONE event, telling you that the semaphore is successfully transferred back to the SPI slave, allowing the SPI slave to receive the next command. 

    Best regards
    Torbjørn

Related