STM32f407+OV7670+USART1上传pc全是0

2019-07-21 02:08发布

大家好,初学f407,做ov7670摄像头实验,图像格式为QCIF(176*144,1帧数据占12672字节:176/2*144/2*2) RGB565。使用帧中断中通过串口1把数据传到pc上,可是PC上看不到图像,十六进制浏览全是0,在论坛里也看了很多相关的帖子,调了好几天都没有解决。所以求助大家,希望大家我分析给些建议。一下是实验配置代码:内存数组定义 uint8_t buf_byte[12672] 
/*OV7670 QCIF RGB565  */
 {0x3a, 0x04},//dummy
{0x40, 0xd0},//565   
{0x12, 0x0c},//QCIF RGB

配置代码:
//DCMI配置
DCMI_InitStructure.DCMI_CaptureMode = DCMI_CaptureMode_Continuous;//????????
  DCMI_InitStructure.DCMI_SynchroMode = DCMI_SynchroMode_Hardware;//????????HSYNC,VSYNC
  DCMI_InitStructure.DCMI_PCKPolarity = DCMI_PCKPolarity_Falling;//PCLK ?????????§
  DCMI_InitStructure.DCMI_VSPolarity = DCMI_VSPolarity_High;//VSYNC ?????????§
  DCMI_InitStructure.DCMI_HSPolarity = DCMI_HSPolarity_High;//HSYNC ?????????§
  DCMI_InitStructure.DCMI_CaptureRate = DCMI_CaptureRate_All_Frame;//????????
  DCMI_InitStructure.DCMI_ExtendedDataMode = DCMI_ExtendedDataMode_8b;//8??????????
  DCMI_Init(&DCMI_InitStructure); 

  NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);
   NVIC_InitStructure.NVIC_IRQChannel = DCMI_IRQn;
 NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority=1;//??????????1
 NVIC_InitStructure.NVIC_IRQChannelSubPriority =3; //×???????3
 NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; //IRQ?¨??????
 NVIC_Init(&NVIC_InitStructure); //?ù?????¨????????????VIC?????÷??

//????DMA Stream 
DMA_DeInit(DMA2_Stream1);
    DMA_InitStructure.DMA_Channel = DMA_Channel_1; //?¨??1 DCMI?¨?? 
  DMA_InitStructure.DMA_PeripheralBaseAddr = (u32)&DCMI->DR; //???è???·??CMI->DR
  DMA_InitStructure.DMA_Memory0BaseAddr = (uint32_t)buf_byte;//DMA ?????÷0???·
  DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralToMemory;//???è???????÷????
  DMA_InitStructure.DMA_BufferSize =1;//?????????? 
  DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;//???è·?????????
  DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;//?????÷????????
  DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Word;//???è?????¤??:32??
  DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte;//?????÷?????¤?? 
  DMA_InitStructure.DMA_Mode = DMA_Mode_Circular;// ???????·???? 
  DMA_InitStructure.DMA_Priority = DMA_Priority_High;//????????
  DMA_InitStructure.DMA_FIFOMode = DMA_FIFOMode_Enable; //FIFO????       
  DMA_InitStructure.DMA_FIFOThreshold = DMA_FIFOThreshold_Full;//??????FIFO 
  DMA_InitStructure.DMA_MemoryBurst = DMA_MemoryBurst_Single;//???è??·?????????
  DMA_InitStructure.DMA_PeripheralBurst = DMA_PeripheralBurst_Single; //?????÷??·????????? 
  DMA_Init(DMA2_Stream1, &DMA_InitStructure);//??????DMA Stream
// DMA_ITConfig(DMA2_Stream1,DMA_IT_TC,ENABLE);

   DCMI_ITConfig(DCMI_IT_FRAME,ENABLE);  
   DCMI_ITConfig(DCMI_IT_VSYNC,ENABLE);  
   DCMI_ITConfig(DCMI_IT_LINE,ENABLE);        
   DCMI_ITConfig(DCMI_IT_ERR, ENABLE);
   DCMI_ITConfig(DCMI_IT_OVF, ENABLE);


帧中断
//DCMI????·???????
void DCMI_IRQHandler(void)
{
if(DCMI_GetITStatus(DCMI_IT_FRAME)==SET)//??????????????
{
DCMI_ClearITPendingBit(DCMI_IT_FRAME);//??????????
 DCMI_CaptureCmd(DISABLE);

    for(i=0;i<BUFSIZE-1;i++)
{   
USART_SendData(USART1,buf_byte); 
      while(USART_GetFlagStatus(USART1,USART_FLAG_TC)==RESET);
}
DCMI_CaptureCmd(ENABLE); 
}
if(DCMI_GetITStatus(DCMI_IT_OVF)==SET)
  {
    DCMI_ClearITPendingBit(DCMI_IT_OVF);
  }
    if(DCMI_GetITStatus(DCMI_IT_ERR)==SET)
  {
    DCMI_ClearITPendingBit(DCMI_IT_ERR);
  }
  if(DCMI_GetITStatus(DCMI_IT_VSYNC)==SET)
  {
   
    DCMI_ClearITPendingBit(DCMI_IT_VSYNC);
  }
  if(DCMI_GetITStatus(DCMI_IT_LINE)==SET)
  {
    DCMI_ClearITPendingBit(DCMI_IT_LINE);
  }
}




友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
该问题目前已经被作者或者管理员关闭, 无法添加新回复
3条回答
正点原子
1楼-- · 2019-07-21 03:48
自己给一个固定数据传输下试试。正常不?
得学会 一个个问题排查。化整为零
chuxue
2楼-- · 2019-07-21 06:45
是的之前我已经试过了给固定值,能发上来,夹杂0。 现在调试出来有数据,不全是零,但是pc端无图像显示,感觉上传数据是错误的。参考别人的代码,有只发低八位,今天打算再试试,也请大家帮忙分析,谢谢原子哥建议。
岁月已无声
3楼-- · 2019-07-21 08:55
回复【3楼】chuxue:
---------------------------------
楼主QCIF图像输出解决了吗?求分享。

一周热门 更多>