ledc_timer_config_t problem

gfia2000
Posts: 12
Joined: Mon Jun 01, 2020 2:17 pm
Location: Argentina

ledc_timer_config_t problem

Postby gfia2000 » Tue Jan 05, 2021 1:42 pm

Hi!

I have the next problem using Arduino core:
In file included from src\main.cpp:8:0:
lib/Salida/Salida.h:9:1: sorry, unimplemented: non-trivial designated initializers not supported
};
When I compile this:

Code: Select all

#include "driver/ledc.h"
#define PIN_S1 GPIO_NUM_4 

ledc_timer_config_t ledc_timer = {
    .speed_mode         = LEDC_HIGH_SPEED_MODE,
    .bit_num            = LEDC_TIMER_10_BIT,
    .timer_num          = LEDC_TIMER_0,
    .freq_hz            = 200
};
 
ledc_channel_config_t ledc_channel = {
    
    .gpio_num   = PIN_S1,
    .speed_mode = LEDC_HIGH_SPEED_MODE,
    .channel    = LEDC_CHANNEL_0,
    .intr_type  = LEDC_INTR_DISABLE,
    .timer_sel  = LEDC_TIMER_0,
    .duty       = 2,
    .hpoint     = 0  
};


S1()
{
    ledc_timer_config(&ledc_timer);
    ledc_channel_config(&ledc_channel);
}
I checked the channel_config_t order cause the code is in .h file...

The Arduino code is the next:

Code: Select all

#include <Salida.h>
void setup(){
S1();
}
void loop(){
}
Anyone can help me?

Thanks!
Hi! I'm a PCB designer and a Uc programmer from Argentinia.

gfia2000
Posts: 12
Joined: Mon Jun 01, 2020 2:17 pm
Location: Argentina

Re: ledc_timer_config_t problem

Postby gfia2000 » Tue Jan 05, 2021 3:41 pm

After many hours, i can finally compile...

The problem is the union{}, but I solve this whit:

Code: Select all

    {.duty_resolution   = LEDC_TIMER_10_BIT}, //Implicit union statment
I hopeful help someone.

Good bye!
Hi! I'm a PCB designer and a Uc programmer from Argentinia.

ESP_Minatel
Posts: 364
Joined: Mon Jan 04, 2021 2:06 pm

Re: ledc_timer_config_t problem

Postby ESP_Minatel » Wed Jan 06, 2021 3:56 pm

Hi,

Thank you by giving us your feedback!

abel-lisco
Posts: 6
Joined: Tue Dec 22, 2020 6:37 pm

Re: ledc_timer_config_t problem

Postby abel-lisco » Tue Jan 12, 2021 1:36 am

Hi,
I went thru the same issue...
If my memory does not fail, the problem is that the C compilers (the one used in Arduino and the one used in esp-idf) are not the same version, and you cannot initialize the members of the structure with the same syntax.
In Arduino, what worked to me, was to initialize each member separately:

ledc_timer.speed_mode = LEDC_HIGH_SPEED_MODE,
ledc_timer.bit_num = LEDC_TIMER_10_BIT,
ledc_timer.timer_num = LEDC_TIMER_0,
ledc_timer.freq_hz = 200

Also, just a couple of days ago I posted a repository at abellisco.github.io/liscolab
there is one folder named ledc-h, which contains an Arduino sketch to configure and prototype interactively using the ledc.h library
you can try configuring with the parameters you want (no coding is necessary), and see if it works. With the available commands you can replicate the example in the ledc_example.c example program (esp-idf example). There is one command available most of the ledc API functions.
Installation instructions are in the same folder, and you'll find the FreeRTOS+CLI library too in the liscolab repository (you need it to have the cli commands)
Also in this sketch you can see how the ledc_timer_config_t structure is initialized.

The sketch also provides you a command "getpulsein" that allows you measure the frequency, the period and the duty cycle of a signal at
the output PIN of the ledc channel (at low frequencies, so you do not need an oscilloscope during the tests).

Hope all of this helps you, we built it having in mind a "protoboard companion" :-), for configuring and testing without coding.

Who is online

Users browsing this forum: No registered users and 46 guests