Open Juan-Elizondo opened 2 months ago
@Juan-Elizondo Thanks for your interest in that example.
I see you set the loop_count
to zero, which means, it will only transmit the packet for once, and then goes into idle state. So you don't need to call rmt_disable
and rmt_enable
within the loop. Please have a try.
Thank you for the reply. It did not work unfortunately. I called rmt disable
and rmt_enable
once after the arming sequence and removed from the loop.
Changed code:
ESP_LOGI(TAG, "Start ESC by sending zero throttle for a while..."); ESP_ERROR_CHECK(rmt_transmit(esc_chan, dshot_encoder, &throttle, sizeof(throttle), &tx_config)); //vTaskDelay(pdMS_TO_TICKS(5000)); vTaskDelay(pdMS_TO_TICKS(2000)); ESP_ERROR_CHECK(rmt_disable(esc_chan)); ESP_ERROR_CHECK(rmt_enable(esc_chan)); tx_config.loop_count = 0; throttle.throttle = 100;
ESP_LOGI(TAG, "Increase throttle, no telemetry"); //for (uint16_t thro = 100; thro < 1000; thro += 10) { // throttle.throttle = thro; while (true) { ESP_ERROR_CHECK(rmt_transmit(esc_chan, dshot_encoder, &throttle, sizeof(throttle), &tx_config)); // the previous loop transfer is till undergoing, we need to stop it and restart, // so that the new throttle can be updated on the output // ESP_ERROR_CHECK(rmt_disable(esc_chan)); // ESP_ERROR_CHECK(rmt_enable(esc_chan)); //vTaskDelay(pdMS_TO_TICKS(1000)); vTaskDelay(pdMS_TO_TICKS(100)); }
Log:
Guru Meditation Error: Core 0 panic'ed (LoadProhibited). Exception was unhandled.
Core 0 register dump: PC : 0x40084569 PS : 0x00060c30 A0 : 0x80084648 A1 : 0x3ffb4100 0x40084569: rmt_tx_mark_eof at C:/Espressif/frameworks/esp-idf-v5.3/components/esp_driver_rmt/src/rmt_tx.c:621
A2 : 0x3ffb4ed4 A3 : 0x3ffb4ed4 A4 : 0x3ffb41e8 A5 : 0x3ffb5254 A6 : 0x3ffb517c A7 : 0x00000000 A8 : 0x00000000 A9 : 0x3ff56844 A10 : 0x3ff56800 A11 : 0x00000012 A12 : 0x3ffb5224 A13 : 0x00000011 A14 : 0x3ffb40f0 A15 : 0x00000030 SAR : 0x00000020 EXCCAUSE: 0x0000001c EXCVADDR: 0x00000018 LBEG : 0x4000c2e0 LEND : 0x4000c2f6 LCOUNT : 0xffffffff 0x4000c2e0: memcpy in ROM 0x4000c2f6: memcpy in ROM
Backtrace: 0x40084566:0x3ffb4100 0x40084645:0x3ffb4120 0x40084811:0x3ffb4150 0x400da1fd:0x3ffb4170 0x400d63d9:0x3ffb41b0 0x400e5a2c:0x3ffb4210 0x400869dd:0x3ffb4240 0x40084566: rmt_tx_mark_eof at C:/Espressif/frameworks/esp-idf-v5.3/components/esp_driver_rmt/src/rmt_tx.c:619 0x40084645: rmt_encode_check_result at C:/Espressif/frameworks/esp-idf-v5.3/components/esp_driver_rmt/src/rmt_tx.c:657 0x40084811: rmt_tx_do_transaction at C:/Espressif/frameworks/esp-idf-v5.3/components/esp_driver_rmt/src/rmt_tx.c:736 0x400da1fd: rmt_transmit at C:/Espressif/frameworks/esp-idf-v5.3/components/esp_driver_rmt/src/rmt_tx.c:577 0x400d63d9: app_main at D:/ESP/DShot/main/dshot_esc_example_main.c:69 0x400e5a2c: main_task at C:/Espressif/frameworks/esp-idf-v5.3/components/freertos/app_startup.c:208 0x400869dd: vPortTaskWrapper at C:/Espressif/frameworks/esp-idf-v5.3/components/freertos/FreeRTOS-Kernel/portable/xtensa/port.c:134
ELF file SHA256: eb91d70e5
Rebooting...
Answers checklist.
IDF version.
v5.3
Espressif SoC revision.
ESP32 revision v3.0
Operating System used.
Windows
How did you build your project?
Command line with idf.py
If you are using Windows, please specify command line type.
PowerShell
Development Kit.
Custom Board
Power Supply used.
External 3.3V
What is the expected behavior?
I have a working implementation for bidirectional dshot using the rmt peripheral on ESP-IDF v5.0. This implementation takes the official rmt dshot_esc as its starting point. The implementation of the bidirectional protocol requires setting the
loop_count
member ofrmt_transmit_config_t
to 0. Otherwise we would be interrupting the processor at too fast a rate when we setup a receive ISR. To keep the ESC from timing out, we then need to use thermt_transmit
function at a fairly high rate.What is the actual behavior?
When updating my ESP-IDF version to v5.3, I started getting runtime crashes on the code that worked on v5.0. I went back to the basic dshot_esc example to reproduce the crashing and verified I can produce the same backtrace with a few modifications to the example.
Steps to reproduce.
I only modified the file dshot_esc_example_main.c from the example.
loop_count
member ofrmt_transmit_config_t
variable tx_config to 0 once the arming sequence is completeThe modified dshot_esc_example_main.c file:
/*
include "freertos/FreeRTOS.h"
include "freertos/task.h"
include "esp_log.h"
include "driver/rmt_tx.h"
include "dshot_esc_encoder.h"
if CONFIG_IDF_TARGET_ESP32H2
define DSHOT_ESC_RESOLUTION_HZ 32000000 // 32MHz resolution, DSHot protocol needs a relative high resolution
else
define DSHOT_ESC_RESOLUTION_HZ 40000000 // 40MHz resolution, DSHot protocol needs a relative high resolution
endif
//#define DSHOT_ESC_GPIO_NUM 0
define DSHOT_ESC_GPIO_NUM GPIO_NUM_23
static const char *TAG = "example";
void app_main(void) { ESP_LOGI(TAG, "Create RMT TX channel"); rmt_channel_handle_t esc_chan = NULL; rmt_tx_channel_config_t tx_chan_config = { .clk_src = RMT_CLK_SRC_DEFAULT, // select a clock that can provide needed resolution .gpio_num = DSHOT_ESC_GPIO_NUM, .mem_block_symbols = 64, .resolution_hz = DSHOT_ESC_RESOLUTION_HZ, .trans_queue_depth = 10, // set the number of transactions that can be pending in the background }; ESP_ERROR_CHECK(rmt_new_tx_channel(&tx_chan_config, &esc_chan));
}
Debug Logs.
More Information.
No response