cancel
Showing results for 
Search instead for 
Did you mean: 

Not getting SPI connection between OV5642

RAnan.3
Associate III

The setup was tested with a arduino platform with the Arducam's github code. The entire working of Camera right from Capturing images to videos from the module(OV5642).

Now I want to migrate to STM controller with the same camera module.

I'm using STM32L496RE to work with Arducam OV5642 module of 5MP configuration.

As an initial step, To verify successful communication between the MCU and the camera module, Iam writing 0X55 to the TEST_REG(0x00) of the OV5642 module and then reading this register to check whether the value is written successfully or not. I'm using STM's HAL Library in STM's cubeide.

Below is my code snippet,

// ***** Spi Transmit ***** //

// 1. Bring slave select low

HAL_GPIO_WritePin(SPI_CS_GPIO_Port, SPI_CS_Pin, GPIO_PIN_RESET);

// 2. Transmit register + data

spiTxBuf[0] = 0x00;

spiTxBuf[1] = 0x55;

HAL_SPI_Transmit(&hspi1,&spiTxBuf, 2, 100);

HAL_GPIO_WritePin(SPI_CS_GPIO_Port, SPI_CS_Pin, GPIO_PIN_SET);

// ***** Spi Receive ***** //

// 1. Bring slave select low

HAL_GPIO_WritePin(SPI_CS_GPIO_Port, SPI_CS_Pin, GPIO_PIN_RESET);

// 2. Transmit register + data

spiTxBuf[0] = 0x00 | 0x80;

HAL_SPI_Transmit(&hspi1,&spiTxBuf, 1, 100);

// 3. Receive data

HAL_SPI_Receive(&hspi1, spiRxBuf, 1, HAL_MAX_DELAY);

// 4. Bring slave select high

HAL_GPIO_WritePin(SPI_CS_GPIO_Port, SPI_CS_Pin, GPIO_PIN_SET);

I'm always getting spiRxBuf as '255', whereas I need to read it as 0x55(which is What I had written in the first step).

I have tried for so long but still not able to establish proper communication. Attached my IOC file for you to know about the configurations of my SPI too.

Mysytem clock frequency = 64Mhz;

Prescaler for SPI = 8;

SPI_SPEED = 64/8 = 8Mhz(Suggested SPI_SPEED for OV5642 module in datasheet)

Calculation for SPI SPEED

Please help as soon as possible.


_legacyfs_online_stmicro_images_0693W00000bj381QAA.png 

0 REPLIES 0