- ESP32S3 RMT !KHz three phase sync test
- setting up channel 0
- I (318) gpio: GPIO[16]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
- setting up channel 1
- I (328) gpio: GPIO[17]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
- setting up channel 2
- I (338) gpio: GPIO[18]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
- Starting Transmitters
- Transmitters Running
- I (348) main_task: Returned from app_main()
attempting to generate 1KHz three phase pulses using RMT
ESP32S3 technical reference manual section 37.2 states
• Four TX channels
• Four RX channels
running the following code which attempts to open three Tx channels
- #include <stdio.h>
- #include <stdbool.h>
- #include <unistd.h>
- // ESP32S3 RMT 1KHz three phase square wave sync test
- #include "driver/rmt_tx.h"
- void app_main(void)
- {
- printf("ESP32S3 RMT !KHz three phase sync test\n");
- //delay(2000);
- // setup Tx channels
- rmt_channel_handle_t tx_channels[3] = { NULL };
- gpio_num_t tx_gpio_number[3] = { GPIO_NUM_16, GPIO_NUM_17, GPIO_NUM_18 }; // pin numbers
- for (int i = 0; i < 3; i++) {
- printf("setting up channel %d\n", i);
- rmt_tx_channel_config_t tx_chan_config = {
- .gpio_num = tx_gpio_number[i],
- .clk_src = RMT_CLK_SRC_DEFAULT,
- .resolution_hz = 1 * 1000 * 1000, // 1MHz clock
- .mem_block_symbols = 64,
- .trans_queue_depth = 1,
- };
- ESP_ERROR_CHECK(rmt_new_tx_channel(&tx_chan_config, &tx_channels[i]));
- }
- rmt_transmit_config_t transmitConfig = {
- .loop_count = -1
- };
- rmt_encoder_handle_t copyEncoder =NULL;
- rmt_copy_encoder_config_t copyEncoderConfig = {};
- assert(rmt_new_copy_encoder(©EncoderConfig, ©Encoder) == ESP_OK && "Failed to Create Copy Encoder");
- ESP_ERROR_CHECK(rmt_enable(tx_channels[2]));
- ESP_ERROR_CHECK(rmt_enable(tx_channels[1]));
- ESP_ERROR_CHECK(rmt_enable(tx_channels[0]));
- // setup sync manage for the three pulses
- rmt_sync_manager_handle_t synchro = NULL;
- rmt_sync_manager_config_t synchro_config = {
- .tx_channel_array = tx_channels,
- .array_size = sizeof(tx_channels) / sizeof(tx_channels[0]),
- };
- ESP_ERROR_CHECK(rmt_new_sync_manager(&synchro_config, &synchro));
- printf("Starting Transmitters\n");
- // setup pulse patterns - clock is 1MHz
- // two 200KHz pulses 40% duty cycle
- const rmt_symbol_word_t pulsePattern1[] = {
- { .duration0 = 500, .level0 = 1, .duration1 = 500, .level1 = 0 },
- };
- const rmt_symbol_word_t pulsePattern2[] = {
- { .duration0 = 333, .level0 = 0, .duration1 = 500, .level1 = 1 },
- { .duration0 = 100, .level0 = 0, .duration1 = 67, .level1 = 0 },
- };
- const rmt_symbol_word_t pulsePattern3[] = {
- { .duration0 = 167, .level0 = 0, .duration1 = 500, .level1 = 1 },
- { .duration0 = 100, .level0 = 0, .duration1 = 233, .level1 = 0 },
- };
- assert(rmt_transmit(tx_channels[0], copyEncoder, &pulsePattern1, sizeof(pulsePattern1), &transmitConfig) == ESP_OK && "Failed to begin transmitting");
- assert(rmt_transmit(tx_channels[1], copyEncoder, &pulsePattern2, sizeof(pulsePattern2), &transmitConfig) == ESP_OK && "Failed to begin transmitting");
- assert(rmt_transmit(tx_channels[2], copyEncoder, &pulsePattern3, sizeof(pulsePattern3), &transmitConfig) == ESP_OK && "Failed to begin transmitting");
- printf("Transmitters Running\n");
- }
- ESP32S3 RMT !KHz three phase sync test
- setting up channel 0
- I (322) gpio: GPIO[16]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
- setting up channel 1
- I (332) gpio: GPIO[17]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
- setting up channel 2
- E (342) rmt: rmt_tx_register_to_group(152): no free tx channels
- E (352) rmt: rmt_new_tx_channel(288): register channel failed
any idea on what the problem is?