cancel
Showing results for 
Search instead for 
Did you mean: 

How do I diagnose the DCMI communicating with a OV7670 sensor when I am not receiving data?

KM.8
Associate III

Hello,

I am trying to get a single image the NUCLEO-L496ZG board with a OV7670 CMOS camera sensor using the DCMI HAL library.

I am trying to read a single image and write to a USB flash drive connected to the NUCLEO board.

I have been trying to use multiple sensors (MT9V024, which was outputting data, but I saw the OV7670 was supported, so I am )

I am not using an LCD screen, but I am trying to get data from the OV7670 sensor without success so far.

I added 15kohm pullup resistors on the I2C datalines.

I am using an oscilloscope to probe the I2C lines and data is going across (I2C clk line is moving , so there is a start condition happening).

I have tried using the stm32L496 Discovery board example, after compiling for my NUCLEO board without success.

I assumed there was a conflict with the BSP and the HAL libraries, so I Googled the following Github post:

https://github.com/take-iwiw/DigitalCamera_STM32/tree/e3ca40f0f960ba3888c8a9f4fec03ff328093363

I did find the DCMI main library file and I am trying to follow it step by step, but I still cannot get any parallel output data from the OV7670 sensor.

Is the following setup overview for DCMI correct using the stm32CubeMX library?

1) MX_DMA_Init();

2) MX_DCMI_Init();

3) {Write configuration registers to OV7670 camera}

4) HAL_DCMI_Start_DMA(sp_hdcmi, DCMI_MODE_SNAPSHOT, destAddress, OV7670_QVGA_WIDTH * OV7670_QVGA_HEIGHT/2);

read destAddress", which is a pointer to "cameraBuffer[320*240+10000]"

5) Write "cameraBuffer[]" array data to the USB flash drive in the "SavePicture()" function that calls "f_write()"

Questions:

1) Is the previous procedure correct for using the DCMI HAL library?

2) Do I need pullups on the DCMI pins {D0 through D7}?

3) Why is the OV7670 chip not sending data over the DCMI parallel bus?

4) If (3) cannot be answered, how do I debug the OV7670 chip sending parallel data?

I posted the DCMI stm32L4 library file and my code if anyone is able to help.

I also posted the OV7670 datasheet for reference

EDIT:

The thing that got me down this rabbit whole is that the cameraBuffer[] array is filled with NULL values when I set a breakpoint in "camera.c line#122" after the Fwrite() function call

Thank you,

Keith

4 REPLIES 4
KM.8
Associate III

I have been able to get data from the OV7670 camera and I can see values in the "cameraBuffer[]" array.

I think the issue was the OV7670 needs an input clock (10-48MHz). I am giving it a 13MHz input clock from stm32 Timer5, channel 3 with frequency of 20 (20MHz clock = 80MHzTimerInputClock / 1 prescaler / 2 period / 2 pulse(50%duty cycle)

The actual measured from Oscilloscope is about 13MHz.

I am seeing data in the expression window like the attached image.

The stm32 keeps reaching a "HardFaultHandler" randomly. Sometimes the code gets into the "SavePicture()" function and sometimes it goes into the "HardFaultHandler".

I trying to write a bitmap file to the USB flash drive and I am debugging also writing a text file to see why the data is not making it to the USB flash drive.

The Bitmap is filled with NULL values.

The text file is showing the correct test characters: 0xA0, 0xB0, 0xC0, 0xD0, 0xF0, 0x0F, 0xFA, 0xFB.

KM.8
Associate III
 
KM.8
Associate III
 
martinj3456
Associate III

Hi Keith1,

Have you solved the issue of image capturing? Just curious about your case and what modifications you made with your previous uploaded project files?

Thanks in advance.

M