Reputation: 13
The problem is that I'm expecting a low frequency (1.25khz) continuous square wave when writing to the PWM output of the ESP32 and what I get is regular/irregular pulsed PWM triangle wave with a 125hz pulse rate (enough for the human eye to see it as flickering.)
Is there any way around this?
I've tried the config below for it:
ledc_timer_config_t ledc_timer_D = {
.duty_resolution = LEDC_TIMER_15_BIT,
.freq_hz = 1250,
.speed_mode = LEDC_HS_MODE,
.timer_num = LEDC_HS_TIMER_2,
.clk_cfg = LEDC_USE_APB_CLK,
};
The output:
I've tried this with the low speed as well and got the same issue, if not an issue when compiling through VS Code IDE.
Upvotes: 0
Views: 138
Reputation: 12708
From the drawing you show in the graph, it seems you are not using a good sampling device and you are sampling at a low rate too. The poligonal shaped traces of the signal indicate that probably you are sampling at the same frequency of the pwm signal or even lower. I should recommend you to oversample (let's say 16 times faster) to see properly shaped square pulses.
Upvotes: 0