(Solved) RMT driver for software UART with 22 bit data possible?

dzungpv
Posts: 36
Joined: Thu Mar 26, 2020 4:52 am

Re: RMT driver for software UART with 22 bit data possible?

Postby dzungpv » Mon Dec 02, 2024 1:33 pm

ok-home wrote:
Mon Dec 02, 2024 12:50 pm
try
https://github.com/ok-home/hbs_rmt_ser ... al.c#L121
and
#define RMT_RX_IDLE_THRES (5000) // from 2400 to 10000
Thank you, it is better now, I tested 15 minutes without any error on real device.

dzungpv
Posts: 36
Joined: Thu Mar 26, 2020 4:52 am

Re: RMT driver for software UART with 22 bit data possible?

Postby dzungpv » Mon Dec 02, 2024 6:34 pm

ok-home wrote:
Mon Dec 02, 2024 12:50 pm
try
https://github.com/ok-home/hbs_rmt_ser ... al.c#L121
and
#define RMT_RX_IDLE_THRES (5000) // from 2400 to 10000
I have other problem, I have 2 test device with ESP32 1 with ESP32C3, 1. ESP32 work, but 1 esp32 crash all the time with:

Code: Select all

assert failed: prvReturnItemDefault ringbuf.c:623
Two devices same code but with difference real device, so old RMT may not stable.

And ESP32C3 crash when flash, it show error:

Code: Select all

CONFLICT! driver_ng is not allowed to be used with the legacy driver
So the old RMT driver could not be use for C3.
I try to migrate to new RMT driver base from your code, but it could not send the data.

The code send the data like this:

Code: Select all

    rmt_transmit_config_t tx_config = {
        .loop_count = 0,
    };
    // Use null encode to send raw symbols
    rmt_copy_encoder_config_t config = {};
    rmt_encoder_handle_t encoder = NULL;
    rmt_new_copy_encoder(&config, &encoder);
    // symbols generate like your code replace rmt_item16_t *rmt_data with native rmt_symbol_word_t* items
   rmt_transmit(tx_channel, encoder, items, item_count, &tx_config);
But it can send only 8 bytes with accurate data, missing 20 bytes

User avatar
ok-home
Posts: 98
Joined: Sun May 02, 2021 7:23 pm
Location: Russia Novosibirsk
Contact:

Re: RMT driver for software UART with 22 bit data possible?

Postby ok-home » Tue Dec 03, 2024 1:06 am

Code: Select all

rmt_transmit(tx_channel, encoder, items, item_count, &tx_config);
item_count must be in bytes

Code: Select all

rmt_transmit(tx_channel, encoder, items, item_count * sizeof(rmt_symbol_word_t), &tx_config);
The transmitter on c3 will work, but the receiver is not sure. I'm not sure if ping/pong will work in the right time.
--esp32c3 - total 4 channels (192*2) 48*2 = 96 bits - for tx/rx - 0 channel tx = 96 bits, 1 channel rx = 3*96 = 284 bits ( uses memory from 1 to 3 channels )

dzungpv
Posts: 36
Joined: Thu Mar 26, 2020 4:52 am

Re: RMT driver for software UART with 22 bit data possible?

Postby dzungpv » Tue Dec 03, 2024 5:11 am

ok-home wrote:
Tue Dec 03, 2024 1:06 am

Code: Select all

rmt_transmit(tx_channel, encoder, items, item_count, &tx_config);
item_count must be in bytes

Code: Select all

rmt_transmit(tx_channel, encoder, items, item_count * sizeof(rmt_symbol_word_t), &tx_config);
The transmitter on c3 will work, but the receiver is not sure. I'm not sure if ping/pong will work in the right time.
--esp32c3 - total 4 channels (192*2) 48*2 = 96 bits - for tx/rx - 0 channel tx = 96 bits, 1 channel rx = 3*96 = 284 bits ( uses memory from 1 to 3 channels )
Yes, it work, also I must set invert_out flag for TX config and invert the encode data like mention in: https://esp32.com/viewtopic.php?t=32727#p111412.

But the data error much with setting in new driver like this:

Code: Select all

    rmt_receive_config_t receive_config = {
        .signal_range_min_ns = 1250,     // the shortest duration for Homebus signal is 104us(1 bit), 1250ns < 104us, valid signal won't be treated as noise
        .signal_range_max_ns = 27456000, // the longest duration for Homebus signal is 2288us (22 bits), 27456000ns > 2288us, the receive won't stop early
    };
and

Code: Select all

    // Define RX channel-specific configuration
    rmt_rx_channel_config_t rmt_rx_config = {
        .clk_src = RMT_CLK_SRC_APB,        // Clock source (APB)
        .resolution_hz = 80000000 / RMT_RX_DIV,  // Resolution in Hz , RMT_RX_DIV = 40
        .mem_block_symbols = rx_mem_block,       // memory block size base on CPU
        .gpio_num = rx_pin,                // GPIO pin for RX
        .flags = {
            // .io_loop_back = false,  // Disable loopback
            .invert_in = false,     // Don't invert the input signal
            .with_dma = false,      // do not need DMA backend
        }};

dzungpv
Posts: 36
Joined: Thu Mar 26, 2020 4:52 am

Re: RMT driver for software UART with 22 bit data possible?

Postby dzungpv » Tue Dec 03, 2024 11:17 am

ok-home wrote:
Tue Dec 03, 2024 1:06 am

Code: Select all

rmt_transmit(tx_channel, encoder, items, item_count, &tx_config);
item_count must be in bytes

Code: Select all

rmt_transmit(tx_channel, encoder, items, item_count * sizeof(rmt_symbol_word_t), &tx_config);
The transmitter on c3 will work, but the receiver is not sure. I'm not sure if ping/pong will work in the right time.
--esp32c3 - total 4 channels (192*2) 48*2 = 96 bits - for tx/rx - 0 channel tx = 96 bits, 1 channel rx = 3*96 = 284 bits ( uses memory from 1 to 3 channels )
Never mind. I change the signal_range_max_ns = 22000000 and it working now.
On the ESP32C3 I can only set maximum 64 symbols for 1 TX channel and 64 symbols for 1 RX channel but it still work fine with 528 bit signal. Thank you again for your help.

Who is online

Users browsing this forum: Majestic-12 [Bot] and 73 guests