mudassar-tamboli / ESP32-OV7670-WebSocket-Camera

Demonstrates Video Streaming from ESP32+OV7670 hardware using WebSocket protocol
Apache License 2.0
79 stars 22 forks source link

Project will no longer run in 2023 #13

Open RudolfAtHome opened 10 months ago

RudolfAtHome commented 10 months ago

I activated the project again this week and can't get it to work! 2 years ago it was working fine. My guess: I'm now using a newer package for the ESP32: 2.0.10 There is a "reliable crash" in the source XClk.cpp, line 18. The error message: _assert failed: ledc_clk_cfg_to_globalclk ledc.c:444 (false)

animevietsub commented 10 months ago

You may select REF_TICK as the source clock, try to use LEDC_USE_APB_CLK Change in XClk.cpp file:

...
ledc_timer_config_t timer_conf;
timer_conf.bit_num = (ledc_timer_bit_t)1;
timer_conf.freq_hz = Hz;
timer_conf.speed_mode = LEDC_HIGH_SPEED_MODE;
timer_conf.timer_num = LEDC_TIMER_0;
timer_conf.clk_cfg = LEDC_USE_APB_CLK;
esp_err_t err = ledc_timer_config(&timer_conf);
if (err != ESP_OK) {
        return false;
}
...
RudolfAtHome commented 10 months ago

To animevietsub: Thanks, with the change the crash is gone. But there is an error message: _E (66519) ledc: ledc_set_duty_with_hpoint(699): hpoint argument is invalid_ I have modified the "" function a bit to display the values: `bool ClockEnable(int pin, int Hz) { periph_module_enable(PERIPH_LEDC_MODULE);

ledc_timer_config_t timer_conf;
timer_conf.duty_resolution = (ledc_timer_bit_t)1;
timer_conf.freq_hz = Hz;
timer_conf.speed_mode = LEDC_HIGH_SPEED_MODE;
timer_conf.timer_num = LEDC_TIMER_0;
timer_conf.clk_cfg = LEDC_USE_APB_CLK;
Serial.println("XClk.cpp before ledc_timer_config(...)");
//---- Debug entry ------------------------------------
Serial.println("Content timer_conf:");
Serial.printf(" speed_mode      = %d\n",timer_conf.speed_mode);
Serial.printf(" duty_resolution = %d\n",timer_conf.duty_resolution);
Serial.printf(" timer_num       = %d\n",timer_conf.timer_num);
Serial.printf(" freq_hz         = %ld\n",timer_conf.freq_hz);
Serial.printf(" clk_cfg         = %d\n",timer_conf.clk_cfg);
//---- end of Debug entry -----------------------------
esp_err_t err = ledc_timer_config(&timer_conf);
if (err != ESP_OK) {
    return false;
}

` The result is this error message: _Before camera... OV7660: Before ClockEnable XClk.cpp before ledc_timer_config(...) Content timer_conf: speed_mode = 0 duty_resolution = 1 timer_num = 0 freq_hz = 20000000 clk_cfg = 1 E (66519) ledc: ledc_set_duty_withhpoint(699): hpoint argument is invalid Waiting for VSYNC:low:Camera with error 3

animevietsub commented 10 months ago

The error hpoint too big, try to set hpoint to 0 in ledc_channel_config_t ch_conf

...
ledc_channel_config_t ch_conf;
    ch_conf.channel = LEDC_CHANNEL_0;
    ch_conf.timer_sel = LEDC_TIMER_0;
    ch_conf.intr_type = LEDC_INTR_DISABLE;
    ch_conf.duty = 1;
    ch_conf.speed_mode = LEDC_HIGH_SPEED_MODE;
    ch_conf.gpio_num = pin;
    ch_conf.hpoint = 0;
...
RudolfAtHome commented 10 months ago

Great, with this little extension it works again! Thanks alot. Unfortunately I can't find the important file "ledc.c", it must be contained in a compiled library. That makes it a black box for me.

animevietsub commented 10 months ago

I can't the location of file ledc.c in Arduino framework neither, but you find it from ESP-IDF https://github.com/cfint/esp-idf/blob/master/components/driver/ledc.c