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

24MHz clock issue #716

Open
3 tasks done
josef2600 opened this issue Jan 21, 2025 · 0 comments
Open
3 tasks done

24MHz clock issue #716

josef2600 opened this issue Jan 21, 2025 · 0 comments

Comments

@josef2600
Copy link

josef2600 commented Jan 21, 2025

Checklist

  • Checked the issue tracker for similar issues to ensure this is not a duplicate.
  • Provided a clear description of your suggestion.
  • Included any relevant context or examples.

Issue or Suggestion Description

hi. frankly, i was happy to see you still working on camera. i don't understand why nobody has fixed this one yet, but i have! currently, i am working in here:
https://github.com/s60sc/ESP32-CAM_MJPEG2SD
but i created a pull request there that fixes the clock issue. i have seen your code, but i didn't quite understand why yours doesn't work. i did test it. but if i do it in espressif way, it works. to remind you, i am working with Arduino. but i do not think there is any problem for it to put it to IDF too.
any way, this is the code that can generate 24MHz or 26MHz or any other clocks. i have tested it with oscilloscope. i do know over 20MHz it is not very good, but i tested it with ov5640 and it had no problem. but not just that, i was able to work with it very very more stable. and it did accept 10FPS for framing at full HD. although, it doesn't generate it for streaming. but that is another problem not related.
here is the code i tested for board v 3.1.1 and esp32-s3 and ov5640.
but, since i do not work with your code directly, i have to use you esp_camera_init and then disable the LEDC.

    err = esp_camera_init(&config); // here it only should be 20mhz
    delay(300);// this is base on datasheet. the camera takes under 300ms to be configured. 
    //since the original setup doesnt create over 20MHz clock, we do it forcefully
    // Deinitialize the existing LEDC configuration
    ledc_stop(LEDC_LOW_SPEED_MODE, config.ledc_channel, 0);
    delay(1); // for fun! but really for making sure it stops! and 
    // Configure the LEDC timer
    ledc_timer_config_t ledc_timer =
    {
      .speed_mode = LEDC_LOW_SPEED_MODE,
      .duty_resolution = LEDC_TIMER_1_BIT,
      .timer_num = config.ledc_timer,
      .freq_hz = config.xclk_freq_hz,
      .clk_cfg = LEDC_AUTO_CLK
    };
    if (ledc_timer_config(&ledc_timer) != ESP_OK)
    {
      LOG_ERR("mjpeg2sd.cpp - ledc_timer_config(&ledc_timer) != ESP_OK");
      delay(1000);
    }
    // Configure the LEDC channel
    ledc_channel_config_t ledc_channel =
    {
      .gpio_num = XCLK_GPIO_NUM,
      .speed_mode = LEDC_LOW_SPEED_MODE,
      .channel = config.ledc_channel,
      .intr_type = LEDC_INTR_DISABLE,
      .timer_sel = config.ledc_timer,
      .duty = 1,  // 50% duty cycle for 1-bit resolution
      .hpoint = 0
    };
    
    if (ledc_channel_config(&ledc_channel) != ESP_OK)
    {
      LOG_ERR("mjpeg2sd.cpp - ledc_channel_config(&ledc_channel) != ESP_OK");
      delay(1000);
    }
    delay(300);//fun fun!

datasheet say put a delay(300);. this is base on datasheet. the camera takes under 300ms to be configured for the settings we gave it.
and this is the test:
https://private-user-images.githubusercontent.com/24930536/402267861-c25c15f6-575b-4b68-99e3-1ec4e22dfd42.jpg?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzc0MTg5MjksIm5iZiI6MTczNzQxODYyOSwicGF0aCI6Ii8yNDkzMDUzNi80MDIyNjc4NjEtYzI1YzE1ZjYtNTc1Yi00YjY4LTk5ZTMtMWVjNGUyMmRmZDQyLmpwZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAxMjElMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMTIxVDAwMTcwOVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTFiNjY0ZTQ0YjdiMTdjMmEyZTFlYWYwNDFiOWQ0OTM2YjE2YjU3MDBhM2NjMGM1MThkMTRjZjgxOTI0OWVlODImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.aFueJcfoo6bsyfo97npRLJhPdeIWhGN371lJf-EwAKg

Image

and if you are interested, this is my discussion and my board pictures!
s60sc/ESP32-CAM_MJPEG2SD#540 (reply in thread)
please check the code.
by the way, all clocks in high frequency are sin wave. the 20mhz is sin way too, but it is more pure. but the camera can handel it since they all have schmitt trigger input

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant