LEDC issue

stock86c
Posts: 18
Joined: Mon Aug 19, 2019 10:15 am

LEDC issue

Postby stock86c » Thu Oct 31, 2019 1:31 am

HI everyone,

i have a application that randomly crashes the ledc pwm( only that, other parts seems to work just fine), but i have no idea how to figure out or do any debug on that issue. The application has wifi + ble enabled, and ledc, i2c peripherals working also. All works fine so it seemed until we noticed that the ledc that controls the brightness of the LED suddenly turns fully ON and loses control. The brightness of the LED is controlled via nRF app , which sends a value of 0-100 to control the brightness. The code is just copied from the standard ledc_example_main, configured as follows:

///LED PWM definitions
#define LEDC_LS_TIMER LEDC_TIMER_1
#define LEDC_LS_MODE LEDC_LOW_SPEED_MODE
#define LEDC_LS_CH2_GPIO (4) //// this is original 4
#define LEDC_LS_CH2_CHANNEL LEDC_CHANNEL_2

#define LEDC_TEST_DUTY (5000)
#define LEDC_TEST_FADE_TIME (1000)
#define LEDC_DELAY_BET_CHG (4000)

static ledc_timer_config_t ledc_timer = {
.duty_resolution = LEDC_TIMER_13_BIT, // resolution of PWM duty
.freq_hz = 5000, // frequency of PWM signal
.speed_mode = LEDC_LS_MODE, // timer mode
.timer_num = LEDC_LS_TIMER // timer index
};

static ledc_channel_config_t ledc_channel2 = {
.channel = LEDC_LS_CH2_CHANNEL,
.duty = 0,
.gpio_num = LEDC_LS_CH2_GPIO,
.speed_mode = LEDC_LS_MODE,
.hpoint = 0,
.timer_sel = LEDC_LS_TIMER
};

static void LED_ON(const ledc_channel_config_t *channel_config, int value ){
//ledc_channel_config_t temp= &channel_config ;
#ifdef DEBUG
printf("1. LEDC fade up to duty = %d\n", 50*(value));
#endif

ledc_set_fade_with_time(channel_config->speed_mode, channel_config->channel, 50*(value), LEDC_TEST_FADE_TIME);
ledc_fade_start(channel_config->speed_mode,channel_config->channel, LEDC_FADE_NO_WAIT);
//vTaskDelay(LEDC_TEST_FADE_TIME / portTICK_PERIOD_MS);
}

As seen above, the code is pretty basic and standard, nothing fancy. While fiddling with the brightness of the LED, we noticed that randomly it gets crashed when adjusting the value from 0-100 , but the ESP32 is still working normally ; the UART can still send messages indicating it is still running, while the i2c is still grabbing data and constantly pushing values to the UUID char at the nRF app.

Has anyone experienced such issues ? Any clues would be appreciated. thx

Note: (I tried to search the forum , but the search post function seems pretty dead, so had to post this rather simple issue hoping to find some help, thx)

Who is online

Users browsing this forum: Baidu [Spider], Majestic-12 [Bot] and 126 guests