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?

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

    Actually, I must rectify a mistake in my previous comment, my apologies.
    It appears that the nRF52832 is still limited to a 255 byte TWI transfer limit, despite using TWIM with easyDMA.
    This is due to the size of the peripheral's TXD.MAXCNT register.
    I discussed this with a colleague, who informed me that even though if you were to use the ArrayList easyDMA feature for the TXD.MAXCNT register, it would still happen in two transfers.
    My thought here was the same as you - that if you suspended with a NO_STOP at the end of the first buffer, you could continue into the next - but here you should instead get a repeated start.
    My apologies for any confusion this might have caused.
    Is this what you were referring to in your initial post?

    Bakry said:
    Thanks for your reply

    No problem at all, I am happy to help!

    Bakry said:
    I will try to verify if it works this week.

    Great, I look forward to hearing any updates.

    Bakry said:
    may I know what is the difference between TWIM library and nrfx_twi? 

    The main difference between the two is that the TWIM driver uses easyDMA by default, while the nrfx_twi driver does not(but still can be configured to do so). This is not the only difference, but it is the most significant one. Please also see the reply by my colleague Einar in this ticket for some more details.

    Best regards,
    Karl

  • Thanks for letting me know. In that case, how to avoid the repeated start?

Reply Children
No Data
Related