ledc component duty update
Posted: Tue Jul 21, 2020 11:46 am
I've got a buzzer connected to a GPIO which I need to toggle repeatedly. Currently I do that with software, i.e FreeRTOS task:
Is there a way of achieving the same effect using ledc_set_fade() or something alike, and use hardware to repeatedly do the toggling?
Thanks
Code: Select all
static void ring()
{
ledc_set_duty(ledc_channel.speed_mode, ledc_channel.channel, 120);
ledc_update_duty(ledc_channel.speed_mode, ledc_channel.channel);
}
static void silent()
{
ledc_set_duty(ledc_channel.speed_mode, ledc_channel.channel, 0);
ledc_update_duty(ledc_channel.speed_mode, ledc_channel.channel);
}
static void buz_task()
{
while (true)
{
ring();
vTaskDelay(200 / portTICK_PERIOD_MS);
silent();
vTaskDelay(100 / portTICK_PERIOD_MS);
}
}
Thanks