Why is there a 15us interval between rmt pulses between two rmt_transmit?

chenkejin
Posts: 11
Joined: Sun Aug 14, 2022 3:38 pm

Why is there a 15us interval between rmt pulses between two rmt_transmit?

Postby chenkejin » Fri Dec 15, 2023 2:39 am

I've noticed in successive calls to the rmt_transmit function that neighboring encoders create intervals. How do I phase out this time?
Image

Code: Select all

        
        rmt_transmit(crs_channel, crs_encoder, &crs_gear_wave[out_index], sizeof(uint16_t), &crs_transmit_config);
        // rmt_transmit(cas_channel, cas_encoder, &cas_gear_wave[out_index], sizeof(uint16_t), &cas_transmit_config);
        rmt_transmit(crs_channel, crs_encoder, &crs_gear_wave[out_index + 1], sizeof(uint16_t), &crs_transmit_config);

Code: Select all

size_t IRAM_ATTR rmt_encode_ir_nec(rmt_encoder_t *encoder, rmt_channel_handle_t channel, const void *primary_data, size_t data_size, rmt_encode_state_t *ret_state)
{
    rmt_ir_nec_encoder_t *nec_encoder = __containerof(encoder, rmt_ir_nec_encoder_t, base);
    rmt_encode_state_t session_state = RMT_ENCODING_RESET;
    rmt_encode_state_t state = RMT_ENCODING_RESET;
    size_t encoded_symbols = 0;
    uint16_t *gear_wave = (uint16_t *)primary_data;
    rmt_encoder_handle_t bytes_encoder = nec_encoder->bytes_encoder;
    switch (nec_encoder->state)
    {
    case 0:
        encoded_symbols += bytes_encoder->encode(bytes_encoder, channel, &gear_wave[0], sizeof(uint16_t), &session_state);
        if (session_state & RMT_ENCODING_COMPLETE)
        {
            nec_encoder->state = RMT_ENCODING_RESET; // back to the initial encoding session
            state |= RMT_ENCODING_COMPLETE;
        }
        if (session_state & RMT_ENCODING_MEM_FULL)
        {
            state |= RMT_ENCODING_MEM_FULL;
            goto out;
        }
        break;
    default:
        nec_encoder->state = RMT_ENCODING_RESET; // back to the initial encoding session
        state |= RMT_ENCODING_COMPLETE;
        break;
    }

out:
    *ret_state = state;
    return encoded_symbols;
}
Attachments
图片1.png
图片1.png (24.6 KiB) Viewed 53482 times

ESP_Sprite
Posts: 9577
Joined: Thu Nov 26, 2015 4:08 am

Re: Why is there a 15us interval between rmt pulses between two rmt_transmit?

Postby ESP_Sprite » Fri Dec 15, 2023 7:16 am

Because finalizing and starting a new transfer takes time. You're probably better off merging those transfers if you want zero overlap.

chenkejin
Posts: 11
Joined: Sun Aug 14, 2022 3:38 pm

Re: Why is there a 15us interval between rmt pulses between two rmt_transmit?

Postby chenkejin » Fri Dec 15, 2023 2:58 pm

ESP_Sprite wrote:
Fri Dec 15, 2023 7:16 am
Because finalizing and starting a new transfer takes time. You're probably better off merging those transfers if you want zero overlap.
I actually tried. I needed the output in an infinite loop, but it failed due to a lack of RMT memory.I think this is transmitor time less than encoder time.

shirogeek
Posts: 15
Joined: Sun Nov 08, 2020 8:07 pm

Re: Why is there a 15us interval between rmt pulses between two rmt_transmit?

Postby shirogeek » Wed Jan 10, 2024 5:39 pm

Did you manage to solve your issue ?

I have the same problem but for a different reason. I have an interactive application where I need to compute a sequence of pulses based on some sensor data I get. I use the rmt to send the pulses in a loop fashion : check sensor -> compute sequence -> send via RMT and I have a solid 15-20 us delay which I believe is for the same reason as you. The computation is quite light so I know it is the RMT causing this and I don't understand why we could not reduce this delay further...

Who is online

Users browsing this forum: Basalt and 339 guests