ledc component duty update

gal-vayyar
Posts: 8
Joined: Sun Jun 21, 2020 3:12 pm

ledc component duty update

Postby gal-vayyar » 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:

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

Who is online

Users browsing this forum: ok-home and 65 guests