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);
}
}
- 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!