Skip to content

Instantly share code, notes, and snippets.

@alg alg/main.c
Created Aug 29, 2019

Embed
What would you like to do?
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); // low is always '0'
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.