Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

esp32c6-Unable to continuously generate LED PWM in light sleep mode. (IDFGH-12713) #13698

Open
3 tasks done
hiroshi3117 opened this issue Apr 26, 2024 · 4 comments
Open
3 tasks done
Labels
Status: Opened Issue is new

Comments

@hiroshi3117
Copy link

Answers checklist.

  • I have read the documentation ESP-IDF Programming Guide and the issue is not addressed there.
  • I have updated my IDF branch (master or release) to the latest version and checked that the issue is present there.
  • I have searched the issue tracker for a similar issue and not found a similar issue.

General issue report

Hi,
I based it on "led_basic_example" and added "esp_light_sleep_start" function. But when entering light sleep, LED PWM stops generating.
I referred to some similar questions and added the following settings before entering light sleep:

  1. clock source select "RC_FAST"
  2. esp_sleep_pd_config(ESP_PD_DOMAIN_RC_FAST, ESP_PD_OPTION_ON);
  3. gpio_sleep_sel_dis(LEDC_OUTPUT_IO);

However, PWM generation cannot be maintained during light sleep.
I'm not sure what settings I'm missing in my program that would help me solve this problem.
Thanks!

IDF version: (master)5.4.0
Development board: ESP32-C6-DevKitM-1
Development Platform: Windows, VS Code
Below are the programs I use.

#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "driver/ledc.h"
#include "esp_err.h"
#include "esp_sleep.h"

#define LEDC_TIMER              LEDC_TIMER_0
#define LEDC_MODE               LEDC_LOW_SPEED_MODE
#define LEDC_OUTPUT_IO          (7) // Define the output GPIO
#define LEDC_CHANNEL            LEDC_CHANNEL_0
#define LEDC_DUTY_RES           LEDC_TIMER_10_BIT 
#define LEDC_DUTY               (16) 
#define LEDC_FREQUENCY          (4000) 

static void example_ledc_init(void)
{
    // Prepare and then apply the LEDC PWM timer configuration
    ledc_timer_config_t ledc_timer = {
        .speed_mode       = LEDC_MODE,
        .duty_resolution  = LEDC_DUTY_RES,
        .timer_num        = LEDC_TIMER,
        .freq_hz          = LEDC_FREQUENCY,  
        .clk_cfg          = LEDC_USE_RC_FAST_CLK
    };
    ESP_ERROR_CHECK(ledc_timer_config(&ledc_timer));

    // Prepare and then apply the LEDC PWM channel configuration
    ledc_channel_config_t ledc_channel = {
        .speed_mode     = LEDC_MODE,
        .channel        = LEDC_CHANNEL,
        .timer_sel      = LEDC_TIMER,
        .intr_type      = LEDC_INTR_DISABLE,
        .gpio_num       = LEDC_OUTPUT_IO,
        .duty           = 0, 
        .hpoint         = 0
    };
    ESP_ERROR_CHECK(ledc_channel_config(&ledc_channel));
}

static void ledc_task(void *args)
{
    // Set the LEDC peripheral configuration
    example_ledc_init();
    ESP_ERROR_CHECK(ledc_set_duty(LEDC_MODE, LEDC_CHANNEL, LEDC_DUTY));
    ESP_ERROR_CHECK(ledc_update_duty(LEDC_MODE, LEDC_CHANNEL));

    esp_sleep_pd_config(ESP_PD_DOMAIN_RC_FAST, ESP_PD_OPTION_ON);
    gpio_sleep_sel_dis(LEDC_OUTPUT_IO); 
  
    while(1) 
    {
        printf("Entering light sleep\n");
         /* Enter sleep mode */
        esp_light_sleep_start();
        vTaskDelay(100/portTICK_PERIOD_MS);
    }
}

void app_main(void)
{
    xTaskCreate(ledc_task, "ledc_task", 4096, NULL, 6, NULL);
}
@espressif-bot espressif-bot added the Status: Opened Issue is new label Apr 26, 2024
@github-actions github-actions bot changed the title esp32c6-Unable to continuously generate LED PWM in light sleep mode. esp32c6-Unable to continuously generate LED PWM in light sleep mode. (IDFGH-12713) Apr 26, 2024
@hiroshi3117
Copy link
Author

Additional my configuration files .

@hiroshi3117
Copy link
Author

I referred to the following post and tested it,but still not work.
espressif/arduino-esp32#3534
#12188

Is there any Espressif engineer who can provide a sample program for ESP32-C6 to continuously generate LEDC PWM in light sleep mode for my reference?
Thanks.

@songruo
Copy link
Collaborator

songruo commented May 6, 2024

Hi @hiroshi3117,

Yes, this feature has not yet been supported on C6/H2. Please hang on with us for a few days, I will do some update or give you a workaround as soon as possible.

@hiroshi3117
Copy link
Author

Hi @songruo ,
Thanks for your reply. My product is about to be mass-produced in the 3Q. If PWM cannot be continuously output in power saving mode, it will cause great trouble to battery life. Please provide this workaround as soon as possible. Thank you very much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Opened Issue is new
Projects
None yet
Development

No branches or pull requests

3 participants