Hi to all, I'm trying to interface the esp32 wroom kit with the camera ov7670. Im able to write - read using i2c to the camera, but to be able to get the pixel data I need to read the output clock from the camara which is configurable (8Mhz to 24Hmhz - my case).
How to read the 24Mhz input clock? I tried to read using low level like GPIO.in and REG_READ(GPIO_IN_REG). Also tried with interrupts but I got nothing.
I tried to read the clock input and set/reset a pin to check in scope but nothing is shown in the scope----??? how? If I read the gpio pin with low freq there is no problem getting the input signal by digitalRead, but higher freq not possible??? the esp32 wroom is a 240Mhz!!! Maybe I'm doing something wrong?
The esp32 is able to generate 40Mhz output freq with gpios, why is not being able to read 24Mhz?
Gastón
Hello there,
I am new here but i think that you should try using a DMA for high speed data transfer which can be configured to work with the RMT .
also here is basic example to configure the RMT that ai suggests
``
#include "driver/rmt.h"
#define RMT_RX_CHANNEL RMT_CHANNEL_0
#define GPIO_INPUT_PIN 18
void init_rmt_rx() {
rmt_config_t rmt_rx;
rmt_rx.channel = RMT_RX_CHANNEL;
rmt_rx.gpio_num = GPIO_INPUT_PIN;
rmt_rx.clk_div = 1; // Adjust as needed
rmt_rx.mem_block_num = 1;
rmt_rx.rmt_mode = RMT_MODE_RX;
rmt_rx.rx_config.filter_en = true;
rmt_rx.rx_config.filter_ticks_thresh = 100;
rmt_rx.rx_config.idle_threshold = 0xFFFF;
rmt_config(&rmt_rx);
rmt_driver_install(rmt_rx.channel, 1000, 0);
}
void app_main() {
init_rmt_rx();
// Add your code to process the RMT data
}
``
hopes for my first reply
The ESP32 Wroom kit should technically be capable of reading a clock signal of 24MHz, but there are a few key factors that might be affecting your ability to read this high-frequency signal:
Key Considerations:
-
GPIO Input Limits: While the ESP32 operates at 240MHz, the actual GPIO input and output performance isn't always as high. The GPIO input reading (especially using
digitalRead
or low-level methods) tends to work efficiently for signals up to about 5MHz. Above this range, it's common to encounter issues due to signal degradation or software-related bottlenecks in reading the GPIO fast enough. -
Direct Register Access: You mentioned using REG_READ(GPIO_IN_REG), which should be more efficient than using higher-level functions like
digitalRead()
. However, the bottleneck might still be in processing the signal rather than just reading it. -
Interrupt Latency: When using interrupts, latency can cause missed pulses at such high frequencies (24MHz). The ESP32's interrupt system isn't optimized to handle signals in the MHz range, leading to dropped clock edges.
Potential Solutions:
-
Use Dedicated Hardware Peripherals:
- RMT (Remote Control) or PCNT (Pulse Counter) peripherals can be used for high-frequency signal counting. The RMT peripheral on the ESP32 is designed for tasks like reading infrared signals and generating high-frequency pulses, making it potentially suitable for capturing a 24MHz clock.
- The I2S peripheral could also be a good choice for capturing pixel data from the OV7670 camera, as it's designed to handle high-speed serial interfaces.
-
Use External Frequency Dividers:
If you're reading a clock at 24MHz and finding it too fast to handle with the ESP32 directly, consider using an external clock divider IC to divide the clock down to a lower frequency (e.g., 12MHz or 8MHz), which might be easier for the ESP32 to read reliably. -
DMA (Direct Memory Access):
For high-speed data streams like the camera interface, the ESP32’s I2S module supports DMA, which can continuously read data at high speeds without overwhelming the CPU. This could allow you to stream data from the camera and process it without manually handling each clock pulse. -
Alternative Camera Interface Methods:
The OV7670 camera is often interfaced with microcontrollers using the I2S peripheral, which can read pixel data efficiently. You could configure the I2S interface to handle the pixel clock (PCLK) from the OV7670, capturing data directly from the camera at 24MHz without having to rely on GPIO interrupts or direct reads.
Next Steps:
- Explore using the RMT peripheral for clock pulse counting.
- Try configuring the I2S interface for camera data capture, which can manage high-speed clocks like the one from the OV7670.
- If all else fails, an external clock divider might simplify reading the clock by reducing its frequency to a manageable level for the ESP32.
thanks to the both of you @sudaiskhan and @coolboy_ankush for your replys and examples. I'll go with I2S.
Regards
Gastón
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.