Is LEDC low speed timer working?

spyromus
Posts: 2
Joined: Wed Aug 28, 2019 6:30 pm

Is LEDC low speed timer working?

Postby spyromus » Wed Aug 28, 2019 6:38 pm

Hi everyone,

I seem can effortlessly make LEDC high speed timer, but no matter what I try I can't make low speed one start counting.

Here's the task I run from the app_main() function:

Code: Select all

void pwm_task(void *pvParameter) { DPORT_SET_PERI_REG_MASK(DPORT_PERIP_CLK_EN_REG, DPORT_LEDC_CLK_EN); DPORT_CLEAR_PERI_REG_MASK(DPORT_PERIP_RST_EN_REG, DPORT_LEDC_RST);

  // 0 - 8MHz, 1 - 80 MHz
  WRITE_PERI_REG(LEDC_CONF_REG, 1 << LEDC_APB_CLK_SEL_S);

  // High speed
  WRITE_PERI_REG(LEDC_HSTIMER0_CONF_REG, LEDC_TICK_SEL_HSTIMER0 | (0b000000001001010100 << LEDC_DIV_NUM_HSTIMER0_S) | (4 << LEDC_HSTIMER0_LIM_S));

  // Low speed
  WRITE_PERI_REG(LEDC_LSTIMER1_CONF_REG, (1 << LEDC_TICK_SEL_LSTIMER1_S) | (0b000000001001010100 << LEDC_DIV_NUM_LSTIMER1_S) | (4 << LEDC_LSTIMER1_LIM_S));
  WRITE_PERI_REG(LEDC_LSTIMER1_CONF_REG, LEDC_LSTIMER1_RST | LEDC_LSTIMER1_PARA_UP);

  while(1) {
    vTaskDelay(100 / portTICK_PERIOD_MS);

    uint32_t l = READ_PERI_REG(LEDC_LSTIMER1_VALUE_REG);
    uint32_t h = READ_PERI_REG(LEDC_HSTIMER0_VALUE_REG);
    printf("TIMER low=%d high=%d\n", l, h);
  }
}
I tried:
- configuring SLOW_SPEED with 8MHz and 80MHz
- changing LEDC_DIV_NUM_LSTIMER1 to higher / lower values
- setting LEDC_LSTIMER1_LIM to 15 and 4
- playing with the LEDC_LSTIMER1_PARA_UP and LEDC_LSTIMER1_RST bits
- checking LSTIMER0 and LSTIMER1

After a day on this I'm getting an impression that low speed timers aren't working at all. Can it be the case? Can anyone spot an error in my config?

Thanks!

spyromus
Posts: 2
Joined: Wed Aug 28, 2019 6:30 pm

Re: Is LEDC low speed timer working?

Postby spyromus » Thu Aug 29, 2019 4:58 am

I think I tried this example code before and then turned away for some reason -- https://github.com/espressif/esp-idf/bl ... ple_main.c

Now that I tried it again, it worked perfectly for 12 channels that I need to drive servos (8 HS and 4 LS).

Even though not critical now, but if someone could still point out what I was doing wrong with registers, that would be very much appreciated.

Who is online

Users browsing this forum: No registered users and 96 guests