OV2640通过I2C到NXP LPC1768微控制器的摄像头模块?

时间:2015-05-09 21:53:47

标签: camera sensor i2c lpc nxp-microcontroller

我是嵌入式设备的新手,甚至是相机传感器的新手 - 请耐心等待。我正在尝试在OV2640相机模块(OV2640 Datasheetmodule with breakout board)之间进行接口。所以我连接了以下内容:

  • OV2640 - LPC1768
  • GND ------- p1(GND)
  • VCC ------- p40(Vout - 3.3V)
  • SDA ------- p28(I2C SDA)
  • SCL ------- p27(I2C SCL)

我试图让它通过SCCB工作,这就是连接I2C的原因。但似乎我无法做到这一点。

这是我现在的代码:

#include <stdio.h>
#include "mbed.h"

Serial pc(USBTX, USBRX); // tx, rx to the PC

I2C cam(p28, p27);      // I2C

int main() {
    pc.printf("Starting new program\r\n");
    cam.start();

    int          addressCOM7  = 0x12;
    int          addressCLKRC = 0x11;
    int          addressCOM2  = 0x09;
    const char   data         = 1;
    int          length       = 8; 
    bool         repeated     = false;
    int          rtn          = -1;

    cam.frequency(400000); 
    pc.printf("Camera I2c set to 400,000Hz \r\n");

    rtn = cam.write(addressCOM7, "1", addressCOM7 + data);
    if ( rtn == 0)pc.printf("COM7 set to 1. \r\n");
    else          pc.printf("Error Setting COM7 to 1. \r\n");
    rtn = cam.write(addressCLKRC, &data, addressCLKRC + data);
    if (rtn == 0) pc.printf("CLKRC set to 1. \r\n");
    else          pc.printf("Error Setting CLKRC to 1. \r\n");
    rtn = cam.write(addressCOM2, &data, addressCOM2 + data);
    if (rtn == 0) pc.printf("COM2 set to 1. \r\n");
    else          pc.printf("Error Setting COM2 to 1. \r\n");

    int address = 0x30;
    char readData[128];

    strcpy (readData,"");

    while(1) {
        cam.read(address, readData, 128);
        wait(2.0);
        pc.printf("1 =  '%s'\r\n", readData);       
    }
}

我无法通过I2C写入或读取 - 我在这里做错了什么?

另外,相信XCLK需要与OV2640模块相连,如何通过LPC1768微控制器实现?

0 个答案:

没有答案