When using the ESP-IDF, there are the LEDC-drivers. Basically, you initialize a timer and a channel, so a matching PWM for your LED is the result.
ledc_channel_config_t.hpointledc_set_duty_with_hpoint(...)Thehpoint parameter comes up a lot of times and most I could find all over the search engines was: keep it at zero.
So what does thishpoint-parameter stand for?
1 Answer1
A few hours later I finally found a resource explaining this - so I thought: might make it a bit more accessible...
Source:https://circuitlabs.net/led-pwm-controller-ledc-of-esp32/
Hpoint (Horizontal Point / Phase Control):Each channel has anhpoint register. This value determines the phase of the PWM signal by defining the timer count value at which the duty cycle begins. For most simple LED dimming, hpoint is set to 0. By using differenthpoint values for channels sharing the same timer, you cancreate phase-shifted PWM signals.
self-answer:hpoint is the phase offset of this channel in the same resolution as the pwm itself.
So, it ranges from [0..2^DUTY_BITS-1]
self-correction: on first sight it can be regarded as a phase offset, but it is not!
As @timemage pointed out, theofficial technical refefrence states in Chapter "28.2.3 - Channels" (pg.630ff):
A channel takes the 20-bit value from the counter of the selected high-speed timer and compares it to a setof two values in order to set the channel output. The first value it is compared to is the content ofLEDC_HPOINT_HSCHn; if these two match, the output will be latched high. The second value is the sum ofLEDC_HPOINT_HSCHn and LEDC_DUTY_HSCHn[24..4]. When this value is reached, the output is latched low.
Basically this means, thatHPoint gives an offset, but rather in the style of a "Phase Gate Control" (Phasenanschnittsteuerung in German):
- a duty cycle still beginns with the internal counter at zero and ends with it reaching [2**duty_bits+1] and wrapping around.
- HPoint shifts the turn_High point as well as the turn_low point
- with HPoint > 0 you won't be able to reach 100% duty
- 1I wanted to add that hpoint (
LEDC_HPOINT_HSCHn)is described in theofficial technical reference manual. Not that it shows well in search results or is particularly accessible. Just that it is not missing entirely. One of the diagrams in the article is from it. It is sometimes good to consult in parallel with articles like these. The "H" probably stands for "high". "hpoint" being something like like "high-level comparator output latchpoint". But, "horizontal" might serve thinking better anyway.timemage– timemage2025-11-16 07:31:14 +00:00CommentedNov 16 at 7:31 - @timemage, this might be better as another answer2025-11-23 04:17:54 +00:00CommentedNov 23 at 4:17
- @St0fF, you are able to tick your own answer.2025-11-23 04:18:32 +00:00CommentedNov 23 at 4:18
Explore related questions
See similar questions with these tags.
