<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Stream data over TWI with start signal only in the beginning of the frame, and one stop at the end of the frame</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/70830/stream-data-over-twi-with-start-signal-only-in-the-beginning-of-the-frame-and-one-stop-at-the-end-of-the-frame</link><description>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: 
 
 I can send up to 255 bytes and it</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 05 Feb 2021 11:32:14 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/70830/stream-data-over-twi-with-start-signal-only-in-the-beginning-of-the-frame-and-one-stop-at-the-end-of-the-frame" /><item><title>RE: Stream data over TWI with start signal only in the beginning of the frame, and one stop at the end of the frame</title><link>https://devzone.nordicsemi.com/thread/293070?ContentTypeID=1</link><pubDate>Fri, 05 Feb 2021 11:32:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:30168f1b-81b0-4546-a445-eb61e32d7afd</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;I am happy to hear that you were able to achieve the extended frame using the TWI driver!&lt;br /&gt;&lt;br /&gt;Thank you for updating me on the progress.&lt;br /&gt;&lt;br /&gt;Please do not hesitate to open a new ticket if you should encounter any issues or questions in the future.&lt;br /&gt;&lt;br /&gt;Good luck with your development!&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Stream data over TWI with start signal only in the beginning of the frame, and one stop at the end of the frame</title><link>https://devzone.nordicsemi.com/thread/292983?ContentTypeID=1</link><pubDate>Thu, 04 Feb 2021 18:11:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1a3ac843-d987-48f1-b4c4-1915be20a4c3</guid><dc:creator>Bakry</dc:creator><description>&lt;p&gt;I confirm that it is working!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Stream data over TWI with start signal only in the beginning of the frame, and one stop at the end of the frame</title><link>https://devzone.nordicsemi.com/thread/291744?ContentTypeID=1</link><pubDate>Thu, 28 Jan 2021 10:43:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:239ee360-b244-41dc-b999-854d069f5cbc</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;After some more digging, it seems to me that you might be able to avoid the repeated start if you use the SUSPENDED flag when grouping the transfers together, with &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fsdk_nrf5_v17.0.2%2Fgroup__nrfx__twi.html&amp;amp;anchor=ga5c9b6d700f27de583917838647057658"&gt;the nrfx_twi_xfer function from the TWI driver&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;The documentation here reads:&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.2/group__nrfx__twi.html#ga5684cab698a35c770a78854e348c2408"&gt;NRFX_TWI_FLAG_SUSPEND&lt;/a&gt;&amp;nbsp;- Transfer will be suspended. This allows for combining multiple transfers into one transaction. Only transactions with the same direction can be combined. To finish the transaction, call the function without this flag.&lt;/em&gt;&lt;em&gt;&lt;/em&gt;&lt;br /&gt;Try this, and let me know if it resolves your issue.&lt;br /&gt;This would of course mean that you wont use easyDMA, but perhaps that is an ok tradeoff here?&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Stream data over TWI with start signal only in the beginning of the frame, and one stop at the end of the frame</title><link>https://devzone.nordicsemi.com/thread/291681?ContentTypeID=1</link><pubDate>Thu, 28 Jan 2021 07:58:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2c339c7a-bd0c-4093-8d35-eb92ae8b6f24</guid><dc:creator>Karl Ylvisaker</dc:creator><description>[quote user="Bakry"]I was also thinking, is there anyway to reset the MAXCNT register after sending a desired amount of bytes less than 255 bytes, so it can progress the rest of the data.[/quote]
&lt;p&gt;By this, do you mean to change the MAXCNT register mid-transfer?&lt;br /&gt;I do not think that change would take effect until the transfer is complete, because the data is already retrieved by the peripheral.&lt;br /&gt;&lt;br /&gt;You could read more about the repeated start in &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.nrf52832.ps.v1.1%2Ftwi.html&amp;amp;anchor=concept_cdz_xtv_sr"&gt;the TWI peripheral documentation&lt;/a&gt;. This is what happens behind the scenes of &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fsdk_nrf5_v17.0.2%2Fgroup__nrfx__twim.html&amp;amp;anchor=gaf9f42bc0fd9d26a9516ff2de689d320f"&gt;the TXTX DESC&lt;/a&gt;&amp;nbsp;- it is two transfers happening with a repeated start.&lt;br /&gt;I do not think there is a way to avoid the repeated start when you are using a START TASK to trigger a second transfer or read.&lt;br /&gt;&lt;br /&gt;Which exact sensor are you working with, and how does it handle a repeated start transfer?&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Stream data over TWI with start signal only in the beginning of the frame, and one stop at the end of the frame</title><link>https://devzone.nordicsemi.com/thread/291363?ContentTypeID=1</link><pubDate>Tue, 26 Jan 2021 18:38:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:15885fac-a199-4cdd-a7ca-7959a6411615</guid><dc:creator>Bakry</dc:creator><description>&lt;p&gt;I was also thinking, is there anyway to reset the MAXCNT register after sending a desired amount of bytes less than 255 bytes, so it can progress the rest of the data. If it is not possible, is it possible to FIFO the data among this register ?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Stream data over TWI with start signal only in the beginning of the frame, and one stop at the end of the frame</title><link>https://devzone.nordicsemi.com/thread/291350?ContentTypeID=1</link><pubDate>Tue, 26 Jan 2021 16:57:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b8978d38-990a-4aa6-bb12-a2dc0da46730</guid><dc:creator>Bakry</dc:creator><description>&lt;p&gt;&lt;span&gt;Thanks for letting me know. In that case, how to avoid the repeated start?&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Stream data over TWI with start signal only in the beginning of the frame, and one stop at the end of the frame</title><link>https://devzone.nordicsemi.com/thread/291347?ContentTypeID=1</link><pubDate>Tue, 26 Jan 2021 16:24:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d2fa82f8-d168-4c9b-907a-f96591de3403</guid><dc:creator>Karl Ylvisaker</dc:creator><description>[quote user="Bakry"]I am using 17.02 SDK. Also, if size_t length can cover bytes over 255, why don&amp;#39;t I use it instead?[/quote]
&lt;p&gt;Actually, I must rectify a mistake in my previous comment, my apologies.&lt;br /&gt;It appears that the nRF52832 is still limited to a 255 byte TWI transfer limit, despite using TWIM with easyDMA.&lt;br /&gt;This is due to the size of the peripheral&amp;#39;s &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.nrf52832.ps.v1.1%2Ftwim.html&amp;amp;anchor=register.TXD.MAXCNT"&gt;TXD.MAXCNT register&lt;/a&gt;.&lt;br /&gt;I discussed this with a colleague, who informed me that even though if you were to use &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.nrf52832.ps.v1.1%2Ftwim.html&amp;amp;anchor=unique_133729755"&gt;the ArrayList easyDMA feature for the TXD.MAXCNT register&lt;/a&gt;, it would still happen in two transfers.&lt;br /&gt;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.&lt;br /&gt;My apologies for any confusion this might have caused.&lt;br /&gt;Is this what you were referring to in your initial post?&lt;/p&gt;
[quote user="Bakry"]Thanks for your reply[/quote]
&lt;p&gt;No problem at all, I am happy to help!&lt;/p&gt;
[quote user="Bakry"]I will try to verify if it works this week.[/quote]
&lt;p&gt;Great, I look forward to hearing any updates.&lt;/p&gt;
[quote user="Bakry"]may I know what is the difference between TWIM library and&amp;nbsp;&lt;span&gt;nrfx_twi?&amp;nbsp;&lt;/span&gt;[/quote]
&lt;p&gt;The main difference between the two is that &lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.2/group__nrf__twim.html"&gt;the TWIM driver uses easyDMA by default&lt;/a&gt;, 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 &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/57267/twi-or-twim-example"&gt;the reply by my colleague Einar in this ticket for some more details&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Stream data over TWI with start signal only in the beginning of the frame, and one stop at the end of the frame</title><link>https://devzone.nordicsemi.com/thread/291143?ContentTypeID=1</link><pubDate>Mon, 25 Jan 2021 20:44:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:afab493e-943f-41c3-a802-e8cb1f131a92</guid><dc:creator>Bakry</dc:creator><description>&lt;p&gt;Thanks for your reply, I have eventually used:&amp;nbsp;&amp;nbsp;&lt;pre class="ui-code" data-mode="text"&gt;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, &amp;amp;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, &amp;amp;xfer, 0);
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I will try to verify if it works this week. In the meantime, may I know what is the difference between TWIM library and&amp;nbsp;&lt;span&gt;nrfx_twi?&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I am using 17.02 SDK. Also, if size_t length can cover bytes over 255, why don&amp;#39;t I use it instead?&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Stream data over TWI with start signal only in the beginning of the frame, and one stop at the end of the frame</title><link>https://devzone.nordicsemi.com/thread/291091?ContentTypeID=1</link><pubDate>Mon, 25 Jan 2021 15:11:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d6914178-fc76-4968-b668-dacc7064e475</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello Bakry,&lt;br /&gt;&lt;br /&gt;Which SDK version are you using? I see from your initial post that you reference nrf_drv_twi_tx&amp;nbsp;from the legacy TWI driver, and you later in your comment reference a function from nrfx_twi.c&lt;br /&gt;I would recommend that you do not use these drivers interchangeably, even though the legacy driver is just forwarding macros to the nrfx implementation in later SDK&amp;#39;s.&lt;br /&gt;&lt;br /&gt;I am not sure I have understood your issue correctly, but if you are trying to send data over 255 bytes you may do so if you are using the TWIM driver rather than the TWI one. The TWIM driver uses easyDMA by default, which then does not suffer from the 255 byte limitation.&lt;br /&gt;I would recommend that you use the nrfx_twim driver for this, and that you use &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fsdk_nrf5_v17.0.2%2Fgroup__nrfx__twi.html&amp;amp;anchor=ga5c9b6d700f27de583917838647057658"&gt;the nrfx_twim_xfer function&lt;/a&gt;&amp;nbsp;for the purpose you describe.&lt;br /&gt;&lt;br /&gt;Please let me know if anything still should be unclear, or if you should encounter any other issues or questions!&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Stream data over TWI with start signal only in the beginning of the frame, and one stop at the end of the frame</title><link>https://devzone.nordicsemi.com/thread/290857?ContentTypeID=1</link><pubDate>Sat, 23 Jan 2021 17:23:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fd188e70-5941-4cb7-bbcd-8141c568f0ee</guid><dc:creator>Bakry</dc:creator><description>&lt;p&gt;I have also noticed this function in nrfx_twi.c:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;typedef struct
{
    nrfx_twi_evt_handler_t  handler;
    void *                  p_context;
    volatile uint32_t       int_mask;
    nrfx_twi_xfer_desc_t    xfer_desc;
    uint32_t                flags;
    uint8_t *               p_curr_buf;
    size_t                  curr_length;
    bool                    curr_tx_no_stop;
    twi_suspend_t           prev_suspend;
    nrfx_drv_state_t        state;
    bool                    error;
    volatile bool           busy;
    bool                    repeated;
    size_t                  bytes_transferred;
    bool                    hold_bus_uninit;
} twi_control_block_t;

static bool twi_transfer(NRF_TWI_Type           * p_twi,
                         twi_control_block_t    * p_cb)
{
    bool stopped = false;
    if (nrf_twi_event_check(p_twi, NRF_TWI_EVENT_STOPPED))
    {
        nrf_twi_event_clear(p_twi, NRF_TWI_EVENT_STOPPED);
        NRFX_LOG_DEBUG(&amp;quot;TWI: Event: %s.&amp;quot;, EVT_TO_STR_TWI(NRF_TWI_EVENT_STOPPED));

        // Delay handling of STOPPED event till the end of events processing procedure.
        // If penultimate byte is received and function gets interrupted for long enough
        // after enabling BB_STOP shortcut, RXDREADY for last byte as well as STOPPED
        // may be active at the same time. Therefore RXREADY has to be processed before STOPPED to
        // acquire last byte before finishing transmission by returning &amp;#39;false&amp;#39;.
        stopped = true;
    }

    if (p_cb-&amp;gt;error)
    {
        nrf_twi_event_clear(p_twi, NRF_TWI_EVENT_ERROR);
        nrf_twi_event_clear(p_twi, NRF_TWI_EVENT_TXDSENT);
        nrf_twi_event_clear(p_twi, NRF_TWI_EVENT_RXDREADY);
    }
    else if (nrf_twi_event_check(p_twi, NRF_TWI_EVENT_ERROR))
    {
        nrf_twi_event_clear(p_twi, NRF_TWI_EVENT_ERROR);
        NRFX_LOG_DEBUG(&amp;quot;TWI: Event: %s.&amp;quot;, EVT_TO_STR_TWI(NRF_TWI_EVENT_ERROR));
        nrf_twi_task_trigger(p_twi, NRF_TWI_TASK_STOP);
        p_cb-&amp;gt;error = true;
    }
    else
    {
        if (nrf_twi_event_check(p_twi, NRF_TWI_EVENT_TXDSENT))
        {
            nrf_twi_event_clear(p_twi, NRF_TWI_EVENT_TXDSENT);
            ++(p_cb-&amp;gt;bytes_transferred);
            NRFX_LOG_DEBUG(&amp;quot;TWI: Event: %s.&amp;quot;, EVT_TO_STR_TWI(NRF_TWI_EVENT_TXDSENT));
            if (nrf_twi_event_check(p_twi, NRF_TWI_EVENT_ERROR))
            {
                nrf_twi_event_clear(p_twi, NRF_TWI_EVENT_ERROR);
                NRFX_LOG_DEBUG(&amp;quot;TWI: Event: %s.&amp;quot;, EVT_TO_STR_TWI(NRF_TWI_EVENT_ERROR));
                nrf_twi_task_trigger(p_twi, NRF_TWI_TASK_STOP);
                p_cb-&amp;gt;error = true;
            }
            else
            {
                if (!twi_send_byte(p_twi, p_cb))
                {
                    return false;
                }
            }
        }
        else if (nrf_twi_event_check(p_twi, NRF_TWI_EVENT_RXDREADY))
        {
            nrf_twi_event_clear(p_twi, NRF_TWI_EVENT_RXDREADY);
            NRFX_LOG_DEBUG(&amp;quot;TWI: Event: %s.&amp;quot;, EVT_TO_STR_TWI(NRF_TWI_EVENT_RXDREADY));
            if (nrf_twi_event_check(p_twi, NRF_TWI_EVENT_ERROR))
            {
                NRFX_LOG_DEBUG(&amp;quot;TWI: Event: %s.&amp;quot;, EVT_TO_STR_TWI(NRF_TWI_EVENT_ERROR));
                nrf_twi_event_clear(p_twi, NRF_TWI_EVENT_ERROR);
                nrf_twi_task_trigger(p_twi, NRF_TWI_TASK_STOP);
                p_cb-&amp;gt;error = true;
            }
            else
            {
                if (!twi_receive_byte(p_twi, p_cb))
                {
                    return false;
                }
            }
        }
    }

    if (stopped)
    {
        p_cb-&amp;gt;prev_suspend = TWI_NO_SUSPEND;
        if (!p_cb-&amp;gt;error)
        {
            p_cb-&amp;gt;error = !xfer_completeness_check(p_twi, p_cb);
        }
        return false;
    }

    return true;
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Is it possible to solve my issue? Is there any documentation to read for this function? I would appreciate any example as well.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>