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

Resume suspended TWIM transmission on nRF52

Hi,

I have a problem with resume suspended TWIM transmission. My goal is to send | START | ADDR | DATA 1 | DATA 2 | STOP | where DATA 1 and DATA 2 will be send in two separate TX transactions without repeated START between them. When I send DATA 1 I use short NRF_TWIM_SHORT_LASTTX_SUSPEND_MASK to suspend transfer after sent last byte. When I get NRF_TWIM_EVENT_SUSPENDED, I setup DMA buffer with DATA 2 and use NRF_TWIM_SHORT_LASTTX_STOP_MASK to generate STOP after sending the last byte of the DATA 2. To start the DATA 2 transfer I suppose to use NRF_TWIM_TASK_RESUME but this task does not start DATA 2 transfer. Only when I use NRF_TWIM_TASK_STARTTX after NRF_TWIM_TASK_RESUME data are transferred but with additional | START | ADDR | which is not what I expect.

So the question is: How to resume TWIM TX with the new buffer without sending additional | START | ADDR | ? Is it possible any way?

Here is a snippet of my code:

    const uint8_t data1[] = "data 1";
    const uint8_t data2[] = "data 2";

    nrf_twim_address_set(pSelf->twim.p_twim, 0x17);

    nrf_twim_event_clear(pSelf->twim.p_twim, NRF_TWIM_EVENT_TXSTARTED);
    nrf_twim_event_clear(pSelf->twim.p_twim, NRF_TWIM_EVENT_STOPPED);
    nrf_twim_event_clear(pSelf->twim.p_twim, NRF_TWIM_EVENT_SUSPENDED);
    nrf_twim_event_clear(pSelf->twim.p_twim, NRF_TWIM_EVENT_LASTTX);

    nrf_twim_tx_buffer_set(pSelf->twim.p_twim, data1, strlen((char*)data1));
    nrf_twim_shorts_set(pSelf->twim.p_twim, NRF_TWIM_SHORT_LASTTX_SUSPEND_MASK);

    nrf_twim_task_trigger(pSelf->twim.p_twim, NRF_TWIM_TASK_STARTTX);
    while (!nrf_twim_event_check(pSelf->twim.p_twim, NRF_TWIM_EVENT_SUSPENDED));

    nrf_twim_event_clear(pSelf->twim.p_twim, NRF_TWIM_EVENT_TXSTARTED);
    nrf_twim_event_clear(pSelf->twim.p_twim, NRF_TWIM_EVENT_STOPPED);
    nrf_twim_event_clear(pSelf->twim.p_twim, NRF_TWIM_EVENT_SUSPENDED);
    nrf_twim_event_clear(pSelf->twim.p_twim, NRF_TWIM_EVENT_LASTTX);

    nrf_twim_tx_buffer_set(pSelf->twim.p_twim, data2, strlen((char*)data2));
    nrf_twim_shorts_set(pSelf->twim.p_twim, NRF_TWIM_SHORT_LASTTX_STOP_MASK);

    nrf_twim_task_trigger(pSelf->twim.p_twim, NRF_TWIM_TASK_RESUME);
    /* I do not want to use STARTTX task but without this transfer did not start */
//    nrf_twim_task_trigger(pSelf->twim.p_twim, NRF_TWIM_TASK_STARTTX);
    while (!nrf_twim_event_check(pSelf->twim.p_twim, NRF_TWIM_EVENT_STOPPED));

Thank you in advance!

Parents
  • Hi,

    I do not think there is any way to prevent a repeated start after switching the buffer and calling the STARTTX task. The only think I can think of would be to use a single buffer that can hold both DATA1 and DATA2, and only suspend the transfer in between and use the RESUME task. This would of course require the combined buffer size of the two transfers to be less than the maximum EasyDMA length of 255 bytes (in nRF52832).

    Best regards,
    Jørgen

Reply
  • Hi,

    I do not think there is any way to prevent a repeated start after switching the buffer and calling the STARTTX task. The only think I can think of would be to use a single buffer that can hold both DATA1 and DATA2, and only suspend the transfer in between and use the RESUME task. This would of course require the combined buffer size of the two transfers to be less than the maximum EasyDMA length of 255 bytes (in nRF52832).

    Best regards,
    Jørgen

Children
Related