野火电子论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 9124|回复: 4

OV7670初始化失败,不知道怎么弄得,还请大家指导一下

[复制链接]
发表于 2015-6-23 07:18:15 | 显示全部楼层 |阅读模式
本帖最后由 qq2216691777 于 2015-6-23 07:22 编辑

我有一个OV7670无FIFO的模块  
XCLK给8Mhz  SOIC  SOID接单片机IO口  PWDN 接GND  RESET高电平  其他的没有接
读取OV7670的寄存器一直读取失败  请问一下这是怎么回事啊?是不是我引脚接线有问题啊
  1. #include "sccb.h"

  2. void SCCB_Init( void )
  3. {
  4.         GPIO_InitTypeDef GPIO_InitStructure;
  5.         RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOE, ENABLE);
  6.         GPIO_InitStructure.GPIO_Pin =  GPIO_Pin_13;
  7.         GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
  8.         GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  9.         GPIO_Init(GPIOC, &GPIO_InitStructure);
  10.         
  11.         GPIO_InitStructure.GPIO_Pin =  GPIO_Pin_0;
  12.         GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_OD;
  13.         GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  14.         GPIO_Init(GPIOE, &GPIO_InitStructure);
  15.         
  16. //                 GPIO_InitStructure.GPIO_Pin =  GPIO_Pin_13 | GPIO_Pin_14;
  17. //         GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
  18. //         GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  19. //         GPIO_Init(GPIOA, &GPIO_InitStructure);
  20. }

  21. void StartSCCB(void)
  22. {
  23.                 SCCB_SDA_OUT();
  24.     SCCB_SDA=1;     //数据线高电平           
  25.     SCCB_SCL=1;            //在时钟线高的时候数据线由高至低
  26.     delay_us(100);  
  27.     SCCB_SDA=0;
  28.     delay_us(100);         
  29.     SCCB_SCL=0;            //数据线恢复低电平,单操作函数必要         
  30. }

  31. //SCCB停止信号
  32. //当时钟为高的时候,数据线的低到高,为SCCB停止信号
  33. //空闲状况下,SDA,SCL均为高电平
  34. void StopSCCB(void)
  35. {
  36.                 SCCB_SDA_OUT();
  37.                 SCCB_SCL=0;
  38.           delay_us(10);
  39.     SCCB_SDA=0;
  40.                 delay_us(50);  
  41.     SCCB_SCL=1;        
  42.     delay_us(50);
  43.     SCCB_SDA=1;        
  44.     delay_us(50);
  45. }

  46. //SCCB,写入一个字节
  47. u8 SCCBwriteByte(u8 dat)
  48. {
  49.         u8 j,res;        
  50.         SCCB_SDA_OUT();        
  51.         for(j=0;j<8;j++) //循环8次发送数据
  52.         {
  53.                 if(dat&0x80)SCCB_SDA=1;        
  54.                 else SCCB_SDA=0;
  55.                 SCCB_SDA=1;        
  56.                 dat<<=1;
  57.                 delay_us(50);
  58.                 SCCB_SCL=1;        
  59.                 delay_us(50);
  60.                 SCCB_SCL=0;                  
  61.         }                        
  62.         SCCB_SDA_IN();                //设置SDA为输入
  63.         delay_us(50);
  64.         SCCB_SCL=1;                        //接收第九位,以判断是否发送成功
  65.         delay_us(50);
  66.         SCCB_SCL=0;
  67.         delay_us(20);
  68.         if(SCCB_READ_SDA)res=0;  //SDA=1发送失败,返回0
  69.         else res=1;         //SDA=0发送成功,返回1
  70.         SCCB_SCL=1;                 
  71.         SCCB_SDA_OUT();                //设置SDA为输出   
  72.         return res;   
  73. }

  74. //SCCB 读取一个字节
  75. //在SCL的上升沿,数据锁存
  76. u8 SCCBreadByte(void)
  77. {
  78.         u8 temp=0,j;   
  79.         SCCB_SDA_IN();//设置SDA为输入  
  80.         for(j=8;j>0;j--) //循环8次接收数据
  81.         {                              
  82.                 delay_us(50);
  83.                 SCCB_SCL=1;
  84.                 delay_us(50);
  85.                 temp=temp<<1;
  86.                 if(SCCB_READ_SDA)temp++;   
  87.                 delay_us(50);
  88.                 SCCB_SCL=0;
  89.         }        
  90.         SCCB_SDA_OUT();                  //设置SDA为输出   
  91.         return temp;
  92. }

  93. /*
  94. -----------------------------------------------
  95.    功能: noAck,用于连续读取中的最后一个结束周期
  96.    参数: 无
  97. 返回值: 无
  98. -----------------------------------------------
  99. */
  100. void noAck(void)
  101. {
  102.         SCCB_SDA_OUT();
  103.         SCCB_SDA=1;        
  104.         delay_us(500);
  105.         SCCB_SCL=1;        
  106.         delay_us(500);
  107.         SCCB_SCL=0;        
  108.         delay_us(500);
  109.         SCCB_SDA=0;        
  110.         delay_us(500);
  111. }


复制代码


回复

使用道具 举报

发表于 2015-6-23 09:01:09 | 显示全部楼层
有可能是线的问题,或者是芯片焊接不好的原因。

话说7670现在基本已经停产了,为啥还有那么多人选用这个sensor
回复 支持 反对

使用道具 举报

发表于 2015-6-23 09:03:08 | 显示全部楼层
你直接用我们的例程来试试,我们也有ov7670的驱动程序
回复 支持 反对

使用道具 举报

 楼主| 发表于 2015-6-23 12:07:28 | 显示全部楼层
flyleaf 发表于 2015-6-23 09:03
你直接用我们的例程来试试,我们也有ov7670的驱动程序

那接线引脚没有问题 对吗
回复 支持 反对

使用道具 举报

发表于 2017-6-6 15:43:59 | 显示全部楼层
flyleaf 发表于 2015-6-23 09:03
你直接用我们的例程来试试,我们也有ov7670的驱动程序

能发个用我们mini板驱动7670的代码吗?
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

联系站长|手机版|野火电子官网|野火淘宝店铺|野火电子论坛 ( 粤ICP备14069197号 ) 大学生ARM嵌入式2群

GMT+8, 2024-5-20 17:55 , Processed in 0.032256 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表