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

I'm having trouble sending more than 256 bytes over TWI.


I'm having trouble sending more than 256 bytes over TWI.

nRF52840
SDK17.0.2

Used Function :

ret_code_t nrf_drv_twi_tx(nrf_drv_twi_t const * p_instance,
                          uint8_t               address,
                          uint8_t const *       p_data,
                          uint8_t               length,
                          bool                  no_stop)


ret_code_t nrf_drv_twi_rx(nrf_drv_twi_t const * p_instance,
                          uint8_t               address,
                          uint8_t *             p_data,
                          uint8_t               length)

I have to send 8,208 Bytes continuously through the TWI interface in the above environment.
There should be no STOP/START bits in the middle.
However, if I divide by 255 bytes and send, there is a STOP/START bit in the middle.
I set no_stop to true , but the STOP/START bit is present.
(no_stop = true)

I've searched Devzone and I have a similar issue. But I can't solve the above problem.

And I have one more question.
I do not know the SUSPEND function in the middle part of the twi_send_byte function as shown below.
Is this part used when transmitting more than 256 bytes of data without STOP/START bit?
Please provide a detailed explanation. Thank you in advance.

static bool twi_send_byte(NRF_TWI_Type          * p_twi,
                          twi_control_block_t   * p_cb)
{
    if (p_cb->bytes_transferred < p_cb->curr_length)
    {
        nrf_twi_txd_set(p_twi, p_cb->p_curr_buf[p_cb->bytes_transferred]);
    }
    else
    {
        if (p_cb->curr_tx_no_stop)
        {
            nrf_twi_task_trigger(p_twi, NRF_TWI_TASK_SUSPEND);
            return false;
        }
        else if(TWI_FLAG_SUSPEND(p_cb->flags))
        {
            nrf_twi_task_trigger(p_twi, NRF_TWI_TASK_SUSPEND);
            p_cb->prev_suspend = TWI_SUSPEND_TX;
            return false;
        }
        else
        {
            nrf_twi_task_trigger(p_twi, NRF_TWI_TASK_STOP);
        }
    }
    return true;
}

  • Hi,

     

    I have to send 8,208 Bytes continuously through the TWI interface in the above environment.
    There should be no STOP/START bits in the middle.
    However, if I divide by 255 bytes and send, there is a STOP/START bit in the middle.
    I set no_stop to true , but the STOP/START bit is present.
    (no_stop = true)

     If I understand your correctly, if you write more than 255 bytes the TWI peripheral will send a STOP/START bit after 255 bytes. Could you share your code that shows how you use the driver? Are you using a driver that was made for the nRF52832? 

     

    I do not know the SUSPEND function in the middle part of the twi_send_byte function as shown below.
    Is this part used when transmitting more than 256 bytes of data without STOP/START bit?
    Please provide a detailed explanation. Thank you in advance.

     The Suspend task is used to temporary pause the transaction. As explained in the product specification:

    The TWI master can be suspended using the SUSPEND task, this can be used when using the TWI master in a low priority interrupt context. When the TWIM enters suspend state, will automatically issue a SUSPENDED event while performing a continuous clock stretching until it is instructed to resume operation via a RESUME task. The TWI master cannot be stopped while it is suspended, thus the STOP task has to be issued after the TWI master has been resumed.

    regards

    Jared 

Related