Created
August 29, 2019 03:41
-
-
Save alg/53271e60dde3b71a785400f1598e9e1b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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