replaced signal generator with ESP32S3 using the RMT to generate the test signals
// ESP32S3 RMT two signals synchroinized
// 1. square wave 100KHz, 1MHz, etc on GPIO 15
// 2. 100uSec pulse every second on GPIO 14
// https://docs.espressif.com/projects/esp-idf/en/v5.3.1/esp32/api-reference/peripherals/rmt.html
// on a ESP32 displays error
// rmt_new_sync_manager(345): sync manager not supported
#include "Arduino.h"
#include "driver/rmt_tx.h"
void setup() {
Serial.begin(115200);
delay(2000);
Serial.println("ESP32S3 RMT two signals synchroinized");
Serial.println(" 1. square wave 100KHz, 1MHz, etc on GPIO 15");
Serial.println(" 2. 100uSec pulse every second on GPIO 14");
delay(2000);
// setup two Tx channels
rmt_channel_handle_t tx_channels[2] = { NULL };
gpio_num_t tx_gpio_number[2] = { GPIO_NUM_15, GPIO_NUM_14 }; // pin numbers
rmt_tx_channel_config_t tx_chan_config_1 = {
.gpio_num = tx_gpio_number[0],
.clk_src = RMT_CLK_SRC_DEFAULT,
.resolution_hz = 20 * 1000 * 1000, // 20MHz clock
.mem_block_symbols = 64,
.trans_queue_depth = 1,
};
ESP_ERROR_CHECK(rmt_new_tx_channel(&tx_chan_config_1, &tx_channels[0]));
rmt_tx_channel_config_t tx_chan_config_2 = {
.gpio_num = tx_gpio_number[1],
.clk_src = RMT_CLK_SRC_DEFAULT,
.resolution_hz = 1000000, // 1MHz clock
.mem_block_symbols = 64,
.trans_queue_depth = 1,
};
ESP_ERROR_CHECK(rmt_new_tx_channel(&tx_chan_config_2, &tx_channels[1]));
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[1]));
ESP_ERROR_CHECK(rmt_enable(tx_channels[0]));
// setup sync manage for the two 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));
Serial.println("Starting Transmitters");
// 100KHz square wave - clock is 20MHz
const rmt_symbol_word_t pulsePattern1[] = {
{ .duration0 = 100, .level0 = 1, .duration1 = 100, .level1 = 0 }, };
// 100uSec pulse every second - clock is 1mHz
const rmt_symbol_word_t pulsePattern2[] = {
// 100uSec pluse
{50,1,50,1,},
// total 1 second period
{24950,0,24950,0,}, // note using 15bit counters - see Layout of RMT Symbols
{25000,0,25000,0,},
{25000,0,25000,0,},
{25000,0,25000,0,},
{25000,0,25000,0,},
{25000,0,25000,0,},
{25000,0,25000,0,},
{25000,0,25000,0,},
{25000,0,25000,0,},
{25000,0,25000,0,},
{25000,0,25000,0,},
{25000,0,25000,0,},
{25000,0,25000,0,},
{25000,0,25000,0,},
{25000,0,25000,0,},
{25000,0,25000,0,},
{25000,0,25000,0,},
{25000,0,25000,0,},
{25000,0,25000,0,},
{25000,0,25000,0,},
// Looping mode needs a Zero ending data to mark the EOF
{ 0, 0, 0, 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");
Serial.println("Transmitters Running");
}
void loop() {
}
e.g. 100KHz signal
serial output of test runs counting pulses up to 4MHz
GPIO 4 100KHz
test Pulse count: 10 frequency 100000Hz
period 999991uSec width = 98uSec frequency 1.00Hz
test Pulse count: 10 frequency 100000Hz
period 999990uSec width = 99uSec frequency 1.00Hz
test Pulse count: 10 frequency 100000Hz
period 999991uSec width = 99uSec frequency 1.00Hz
test Pulse count: 10 frequency 100000Hz
period 999991uSec width = 99uSec frequency 1.00Hz
test Pulse count: 10 frequency 100000Hz
period 999991uSec width = 99uSec frequency 1.00Hz
test Pulse count: 10 frequency 100000Hz
period 999991uSec width = 99uSec frequency 1.00Hz
test Pulse count: 10 frequency 100000Hz
period 999991uSec width = 99uSec frequency 1.00Hz
test Pulse count: 10 frequency 100000Hz
period 999991uSec width = 99uSec frequency 1.00Hz
test Pulse count: 10 frequency 100000Hz
period 999991uSec width = 99uSec frequency 1.00Hz
test Pulse count: 10 frequency 100000Hz
----------------------------------------------------
GPIO 4 1MHz signal
test Pulse count: 100 frequency 1000000Hz
period 999991uSec width = 99uSec frequency 1.00Hz
test Pulse count: 100 frequency 1000000Hz
period 999992uSec width = 99uSec frequency 1.00Hz
test Pulse count: 100 frequency 1000000Hz
period 999991uSec width = 99uSec frequency 1.00Hz
test Pulse count: 100 frequency 1000000Hz
period 999992uSec width = 99uSec frequency 1.00Hz
test Pulse count: 100 frequency 1000000Hz
period 999991uSec width = 99uSec frequency 1.00Hz
test Pulse count: 100 frequency 1000000Hz
period 999992uSec width = 98uSec frequency 1.00Hz
test Pulse count: 100 frequency 1000000Hz
period 999992uSec width = 98uSec frequency 1.00Hz
test Pulse count: 100 frequency 1000000Hz
period 999991uSec width = 99uSec frequency 1.00Hz
test Pulse count: 100 frequency 1000000Hz
period 999992uSec width = 99uSec frequency 1.00Hz
test Pulse count: 100 frequency 1000000Hz
period 999991uSec width = 99uSec frequency 1.00Hz
test Pulse count: 100 frequency 1000000Hz
period 999992uSec width = 98uSec frequency 1.00Hz
test Pulse count: 100 frequency 1000000Hz
period 999991uSec width = 99uSec frequency 1.00Hz
test Pulse count: 100 frequency 1000000Hz
----------------------------------------------------------------
2MHz
period 999991uSec width = 99uSec frequency 1.00Hz
test Pulse count: 200 frequency 2000000Hz
period 999992uSec width = 98uSec frequency 1.00Hz
test Pulse count: 200 frequency 2000000Hz
period 999991uSec width = 99uSec frequency 1.00Hz
test Pulse count: 200 frequency 2000000Hz
period 999991uSec width = 99uSec frequency 1.00Hz
test Pulse count: 200 frequency 2000000Hz
period 999991uSec width = 99uSec frequency 1.00Hz
test Pulse count: 200 frequency 2000000Hz
period 999991uSec width = 99uSec frequency 1.00Hz
test Pulse count: 200 frequency 2000000Hz
period 999992uSec width = 98uSec frequency 1.00Hz
test Pulse count: 200 frequency 2000000Hz
period 999991uSec width = 99uSec frequency 1.00Hz
test Pulse count: 200 frequency 2000000Hz
period 999991uSec width = 99uSec frequency 1.00Hz
test Pulse count: 200 frequency 2000000Hz
period 999991uSec width = 99uSec frequency 1.00Hz
test Pulse count: 200 frequency 2000000Hz
period 999991uSec width = 99uSec frequency 1.00Hz
test Pulse count: 200 frequency 2000000Hz
period 999992uSec width = 98uSec frequency 1.00Hz
test Pulse count: 200 frequency 2000000Hz
period 999991uSec width = 99uSec frequency 1.00Hz
test Pulse count: 200 frequency 2000000Hz
period 999991uSec width = 99uSec frequency 1.00Hz
test Pulse count: 200 frequency 2000000Hz
period 999991uSec width = 99uSec frequency 1.00Hz
------------------------------------------------------------
4MHz
test Pulse count: 4 frequency 40000Hz
period 534287uSec width = 8090521uSec frequency 1.87Hz
test Pulse count: 1 frequency 10000Hz
period 534287uSec width = 10990883uSec frequency 1.87Hz
test Pulse count: 400 frequency 4000000Hz
period 10991020uSec width = 99uSec frequency 0.09Hz
test Pulse count: 400 frequency 4000000Hz
period 999992uSec width = 98uSec frequency 1.00Hz
test Pulse count: 400 frequency 4000000Hz
period 999990uSec width = 99uSec frequency 1.00Hz
test Pulse count: 400 frequency 4000000Hz
period 999991uSec width = 99uSec frequency 1.00Hz
test Pulse count: 400 frequency 4000000Hz
period 999991uSec width = 99uSec frequency 1.00Hz
test Pulse count: 400 frequency 4000000Hz
period 999991uSec width = 99uSec frequency 1.00Hz
test Pulse count: 400 frequency 4000000Hz
period 999991uSec width = 99uSec frequency 1.00Hz
test Pulse count: 400 frequency 4000000Hz
period 999991uSec width = 99uSec frequency 1.00Hz
test Pulse count: 400 frequency 4000000Hz
period 999991uSec width = 99uSec frequency 1.00Hz
test Pulse count: 400 frequency 4000000Hz
period 999991uSec width = 99uSec frequency 1.00Hz
test Pulse count: 400 frequency 4000000Hz
period 999991uSec width = 99uSec frequency 1.00Hz
