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

Using SPI transaction manager for flash in scheduled mode

I am using version 15.2 of the SDK.  I am trying to use the SPI transaction manager for reading/writing a SPI flash using the scheduled mode.  I am getting callbacks, but the rx_buffer is not getting updated.  Using the blocking "perform" mode of the transaction manager actually works.  It is only the schedule mode that I am having issues with.  Thanks!

Parents
  • Can you post your code? I'm using the spi_mngr and it works fine.

  • #define OPCODE_READ             0x03

    static uint8_t rx_buf[256];
    static uint8_t const tx_buf[] = { OPCODE_READ, 0, 0, 0};
    static nrf_spi_mngr_transfer_t const transfers_cmd[] = {
        NRF_SPI_MNGR_TRANSFER(tx_buf, 4, rx_buf, 6)
    };


    static void read_block_begin_cb(void *p_user_data)
    {
    NRF_LOG_DEBUG("Start SPI flash read block.");
    }


    static void read_block_end_cb(ret_code_t result, void *p_user_data)
    {
    bool *x = p_user_data;
    *x = true;
    NRF_LOG_DEBUG("End SPI flash read block.");
    }


    bool Read_Block(uint32_t StartAddress, uint8_t *DataPointer, uint32_t DataLength)
    {
    ret_code_t err_code;
    static bool done;

    static nrf_spi_mngr_transaction_t const transaction_cmd =
    {
    .begin_callback = read_block_begin_cb,
    .end_callback = read_block_end_cb,
    .p_user_data = &done,
    .p_transfers = &transfers_cmd,
    .number_of_transfers = 1,
    .p_required_spi_cfg = NULL
    };

    err_code = nrf_spi_mngr_schedule(&m_nrf_spi_mngr, &transaction_cmd);
    if (err_code != 0) return true;
    while(done == false);

    return false;
    }

  • Mm it seems correct to me. What have you done to conclude that the rx buffer is not getting updated?

    If perform works, schedule should work as well, since perform uses schedule internally.

  • Agreed.  Hence my posting of this question.  It should be working, but it's not.  I filled the rx_buffer with known data, did a read from the SPI using the scheduler, and the buffer was unchanged even though both start and end callbacks were called.  Either the SPI flash was not read from, the data went somewhere else, I have a mistake in my code, or there is a bug in the schedule code in the SDK.

Reply
  • Agreed.  Hence my posting of this question.  It should be working, but it's not.  I filled the rx_buffer with known data, did a read from the SPI using the scheduler, and the buffer was unchanged even though both start and end callbacks were called.  Either the SPI flash was not read from, the data went somewhere else, I have a mistake in my code, or there is a bug in the schedule code in the SDK.

Children
Related