0

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.hpoint
ledc_set_duty_with_hpoint(...)

The hpoint 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 this hpoint-parameter stand for?

1 Answer 1

2

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 an hpoint 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 different hpoint values for channels sharing the same timer, you can create 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, the official 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 set of two values in order to set the channel output. The first value it is compared to is the content of LEDC_HPOINT_HSCHn; if these two match, the output will be latched high. The second value is the sum of LEDC_HPOINT_HSCHn and LEDC_DUTY_HSCHn[24..4]. When this value is reached, the output is latched low.

Basically this means, that HPoint 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
3
  • 1
    I wanted to add that hpoint (LEDC_HPOINT_HSCHn) is described in the official 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 latch point". But, "horizontal" might serve thinking better anyway. Commented Nov 16 at 7:31
  • @timemage, this might be better as another answer Commented yesterday
  • @St0fF, you are able to tick your own answer. Commented yesterday

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.