Odd I2C syntoms (Mr. Kolban please have a look)

ats3788
Posts: 21
Joined: Thu Feb 01, 2018 10:12 am

Odd I2C syntoms (Mr. Kolban please have a look)

Postby ats3788 » Wed Jul 11, 2018 4:33 pm

Hello I have a Odd Problem with the SCCB Interface of a OV7670 Camera Modul
I can read The Register if I do this in a loop but it is not working if i try it directly
See code

I use the SCCB Library from the RTOS Project
https://github.com/igrr/esp32-cam-demo/ ... era/sccb.c
and try to convert it to a Arduino Project.
I changed the Resistors for the I2C Pullups I altered
the dcount Integer. Without success.
if(freq <= 100000) twi_dcount = 30;//about 100KHz

Code: Select all


  printf("Initializing Camera on SDA %d and SCL  %d \n", SIOD, SIOC);
   SCCB_Init(SIOD, SIOC);

   ESP_LOGD(TAG_OV7670, "Reset Camera !! \n ");

   digitalWrite(RST, LOW);
   delay(10);
   digitalWrite(RST, HIGH);
   delay(10);

   ESP_LOGD(TAG, "Searching for camera address \n");
  uint8_t slv_addr = SCCB_Probe();
	  s_state.slv_addr = slv_addr;
	  

printf("Camera at address=0x%02x  \n", slv_addr);
	  
	  const int REG_PID = 0x0A; /* Product ID Number MSB */
	  const int REG_VER = 0x0B; /* Product ID Number LSB */
	  const int REG_MIDH = 0x1C; /* Manufacturer ID Byte – High */
	  const int REG_MIDL = 0x1D; /* Manufacturer ID Byte – Low */

	  
	  s_state.config.PID = SCCB_Read(slv_addr, REG_PID); // does not work !!
	  s_state.config.VER = SCCB_Read(slv_addr, REG_VER);    // does not work !!
	  s_state.config.MIDL = SCCB_Read(slv_addr, REG_MIDL);  // does not work !!
	  s_state.config.MIDH = SCCB_Read(slv_addr, REG_MIDH);  // does not work !!
	  
	  delay(10);
	  printf("Camera PID=0x%02x VER=0x%02x MIDL=0x%02x MIDH=0x%02x \n",
	  s_state.config.PID, s_state.config.VER, s_state.config.MIDH, s_state.config.MIDL);
	    	  
	  int Array[100];


	  int dummy;
	  // This is working
	  for (int i = 0; i < 99; i++)

	  {
		  dummy = SCCB_Read(slv_addr, i);
		  printf("I @ 0x%2x  - PID 0x%2x  \n", i, dummy);
		  Array[i] = dummy;
		  delay(10);
	  }

	  s_state.config.PID = Array[REG_PID]; // is working
	  s_state.config.VER = Array[REG_VER];
	  s_state.config.MIDH = Array[REG_MIDH];
	  s_state.config.MIDL = Array[REG_MIDL];


User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: Odd I2C syntoms (Mr. Kolban please have a look)

Postby kolban » Wed Jul 11, 2018 5:23 pm

Do you have a logic analyzer? When I'm working with I2C or SPI I can't even begin to debug puzzles of this nature without attaching one and then mapping what is happening against the data sheet. I have studied the code camera code produced by @igrr and at one time convinced myself that I understood a little of it. What I seem to remember is that the SCCB is no more and no less that I2C (from memory).

Unfortunately, there are too few hours in the day to allow me to come back and study this code in depth again. Are you familiar with I2C protocols? Can you code to ESP-IDF I2C APIs? Are you familiar with the data protocols of the OV7670 device? (I'm not). If it were me, I'd trace each of the messages sent and received from the ESP32 to the device and write those down slowly and carefully. I would examine what is being sent/received and does it match my expectations based on the data sheets. Where it doesn't that's where I'd pay the most attention.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

ats3788
Posts: 21
Joined: Thu Feb 01, 2018 10:12 am

Re: Odd I2C syntoms (Mr. Kolban please have a look)

Postby ats3788 » Thu Jul 12, 2018 10:40 am

Thank you Mr. Koban you are a smart Guy I bought your ESP8266 and ESP32 book and I read that you had questions to Ivan Grokhotkov.
I have to Program a simple SCCB Scanner so I can trace the hole thing. I wish you all the good things in live. Thank you

Mr. Koban

ats3788
Posts: 21
Joined: Thu Feb 01, 2018 10:12 am

Re: Odd I2C syntoms (Mr. Kolban please have a look) (solved)

Postby ats3788 » Fri Jul 13, 2018 1:32 pm

I solved my Problem.
First I checked the Connection with my Logic Analyser, without Success.
Then I checked every Line and wrote me a SCCB Scanner wit the sccb.h Libs and I figured out you need the 10 MHz Clock so that the
OV7670 SCCB Interface works. Then I used Pin 11 for the Reset Line but GPIO11 is used for Internal Purpose ( Flashing ???), if I'm right, so this Pin was always high. The main reason that I got the strange behavior, and finally I had to pull UP the Camera Pin PWDN. Why that I don't know all schematics pull this Pin with 10k down. But now it's working at that is what's counts.
Thank you Forum.

Who is online

Users browsing this forum: No registered users and 16 guests