LEDC Block

How this block appears in a Simulink model?


What can be configured?

Configuration Parameter Selectable Option/Value Description
Duty Resolution LEDC_TIMER_1_BIT to LEDC_TIMER_20_BIT Select the duty resolution
PWM Frequency (Hz) Select the PWM frequency
Timer Speed Mode LED_HIGH_SPEED_MODE--LED_LOW_SPEED_MODE Select the LEDC driver speed mode
Source Clock If the value for this parameter is LEDC_AUTO_CLOCK, the clock will be selected automatically
Hide unused channel configurations on--off The channels assigned Do not use will be hidden
hpoint specify the hpoint
Duty Cycle Mode Using hardware--Using software Select the duty cycle mode. the Duty cycle mode will also change the input method (from mask or from input port) for this parameter
Fade function ledc_set_fade_time_and_start--ledc_set_fade_step_and_start In the hardware mode the user will be able to select the fade function to be used
Target Duty Specify the target duty. The maximum of this parameter depend on the timer configurations. Check reference for more information
Max Fade Time (milliseconds) Specify the time duration for the fade
Fade Mode LEDC_FADE_NO_WAIT--LEDC_FADE_DONE Select fade mode
Scale Select scale
Cycle Number Select cycle number

When to use this block?

This block is designed to control LED intensity using PWM signals. This block could be used for other similar applications involving PWM signal generation as well.

How does this block work?

  • The ESP32 family has 8 high speed channels and 8 low speed channels while ESP32-S2 has 8 low speed channels to generate LED PWM.
  • There are four Timer modules to be selected.
  • When the PWM frequency increases the resolution decreases.


Check LED Control documentation of ESPRESSIF


LEDC demo

Previous : SD Card Block
Next : MCPWM Block

Also available in: PDF HTML TXT