Forum: Mikrocontroller und Digitale Elektronik ESP32 LEDC LEDC_AUTO_CLK Not found


von TR.0LL (Gast)


Lesenswert?

Hallo,

ich will eine LED mit einem ESP32 und LEDC ansteuern.
Ich habe das Problem, dass LEDC_AUTO_CLK nicht gefunden wird.

IDE: Arduino IDE 1.8.12

Code:
1
#include "driver/ledc.h"
2
3
#define LEDC_HS_TIMER          LEDC_TIMER_0
4
#define LEDC_HS_MODE           LEDC_HIGH_SPEED_MODE
5
#define LEDC_HS_CH0_GPIO       (18)
6
#define LEDC_HS_CH0_CHANNEL    LEDC_CHANNEL_0
7
#define LEDC_HS_CH1_GPIO       (19)
8
#define LEDC_HS_CH1_CHANNEL    LEDC_CHANNEL_1
9
#define LEDC_LS_TIMER          LEDC_TIMER_1
10
#define LEDC_LS_MODE           LEDC_LOW_SPEED_MODE
11
#define LEDC_AUTO_CLK
12
void setup() {
13
  ledc_timer_config_t ledc_timer = {
14
    .duty_resolution = LEDC_TIMER_16_BIT, // resolution of PWM duty
15
    .freq_hz = 5000,                      // frequency of PWM signal
16
    .speed_mode = LEDC_LS_MODE,           // timer mode
17
    .timer_num = LEDC_LS_TIMER,            // timer index
18
    .clk_cfg = LEDC_AUTO_CLK,              // Auto select the source clock
19
  };
20
  // Set configuration of timer0 for high speed channels
21
  ledc_timer_config(&ledc_timer);
22
}
23
24
void loop() {
25
  // put your main code here, to run repeatedly:
26
27
}

Fehler:
1
C:\Users\Admin\AppData\Local\Temp\arduino_modified_sketch_136460\sketch_may30a.ino: In function 'void setup()':
2
3
sketch_may30a:18:16: error: 'LEDC_AUTO_CLK' was not declared in this scope
4
5
     .clk_cfg = LEDC_AUTO_CLK,              // Auto select the source clock
6
7
                ^
8
9
sketch_may30a:19:3: error: 'ledc_timer_config_t' has no non-static data member named 'clk_cfg'
10
11
   };
12
13
   ^
14
15
exit status 1
16
'LEDC_AUTO_CLK' was not declared in this scope

Ich möchte gerne die Library nehmen (#include "driver/ledc.h"), weil 
Fading in Hardware damit möglich ist.
https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/peripherals/ledc.html#_CPPv423ledc_set_fade_with_step11ledc_mode_t14ledc_channel_t8uint32_t8uint32_t8uint32_t

von John Doe (Gast)


Lesenswert?

Die Frage ist nicht ernst gemeint, oder???

von TR.0LL (Gast)


Lesenswert?

Kennt niemand eine Lösung dafür.

von John Doe (Gast)


Lesenswert?

TR.0LL schrieb:
> Kennt niemand eine Lösung dafür.

Doch: Lerne C.

Den Arduino-Blödsinn kenne ich nicht, aber da Du mit
1
#include "driver/ledc.h"
die ledc.h inkludierst, bekommst Du auch die ledc_types.h mit 
inkludiert.
Wieso zum Henker löscht Du dann LEDC_AUTO_CLK wieder?

Also entweder:
1
#define LEDC_AUTO_CLK   0
da
1
typedef enum {
2
    LEDC_AUTO_CLK = 0,    /*!< The driver will automatically select the source clock(REF_TICK or APB) based on the giving resolution and duty parameter when init the timer*/
3
    LEDC_USE_REF_TICK,    /*!< LEDC timer select REF_TICK clock as source clock*/
4
    LEDC_USE_APB_CLK,     /*!< LEDC timer select APB clock as source clock*/
5
    LEDC_USE_RTC8M_CLK,   /*!< LEDC timer select RTC8M_CLK as source clock. Only for low speed channels and this parameter must be the same for all low speed channels*/
6
#ifdef SOC_LEDC_SUPPORT_XTAL_CLOCK
7
    LEDC_USE_XTAL_CLK,    /*!< LEDC timer select XTAL clock as source clock*/
8
#endif
9
} ledc_clk_cfg_t;

oder besser den ganzen #define-Schwachsinn wegmachen.

So, und jetzt erstmal ein C-Anfängerbuch besorgen!

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.