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

Stream data over TWI with start signal only in the beginning of the frame, and one stop at the end of the frame

Hello,

I am working on a sensor which requires data transfer over with data length over 255 bytes. I am using nRF52832 uC and and from what I see from nordic infocenter by using the following portion of code:

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);

I can send up to 255 bytes and it is possible to set no_stop to true to not send a stop signal. However as you know, the simple write burst operation has a message similar to this message,  , but that case isn't true, when Data Frame xxx is bigger than 255, since after each data frame, no start signal is resent.

Parents
  • Thanks for your reply, I have eventually used:  

    nrfx_err_t nrfx_twi_tx(nrfx_twi_t const * p_instance,
                           uint8_t            address,
                           uint8_t    const * p_data,
                           size_t             length,
                           bool               no_stop)
    {
        nrfx_twi_xfer_desc_t xfer = NRFX_TWI_XFER_DESC_TX(address, (uint8_t*)p_data, length);
        return nrfx_twi_xfer(p_instance, &xfer, no_stop ? NRFX_TWI_FLAG_TX_NO_STOP : 0);
    }
    
    nrfx_err_t nrfx_twi_rx(nrfx_twi_t const * p_instance,
                           uint8_t            address,
                           uint8_t *          p_data,
                           size_t             length)
    {
        nrfx_twi_xfer_desc_t xfer = NRFX_TWI_XFER_DESC_RX(address, p_data, length);
        return nrfx_twi_xfer(p_instance, &xfer, 0);
    }

    I will try to verify if it works this week. In the meantime, may I know what is the difference between TWIM library and nrfx_twi? 

    I am using 17.02 SDK. Also, if size_t length can cover bytes over 255, why don't I use it instead?

Reply
  • Thanks for your reply, I have eventually used:  

    nrfx_err_t nrfx_twi_tx(nrfx_twi_t const * p_instance,
                           uint8_t            address,
                           uint8_t    const * p_data,
                           size_t             length,
                           bool               no_stop)
    {
        nrfx_twi_xfer_desc_t xfer = NRFX_TWI_XFER_DESC_TX(address, (uint8_t*)p_data, length);
        return nrfx_twi_xfer(p_instance, &xfer, no_stop ? NRFX_TWI_FLAG_TX_NO_STOP : 0);
    }
    
    nrfx_err_t nrfx_twi_rx(nrfx_twi_t const * p_instance,
                           uint8_t            address,
                           uint8_t *          p_data,
                           size_t             length)
    {
        nrfx_twi_xfer_desc_t xfer = NRFX_TWI_XFER_DESC_RX(address, p_data, length);
        return nrfx_twi_xfer(p_instance, &xfer, 0);
    }

    I will try to verify if it works this week. In the meantime, may I know what is the difference between TWIM library and nrfx_twi? 

    I am using 17.02 SDK. Also, if size_t length can cover bytes over 255, why don't I use it instead?

Children
Related