最近在做用STM32mini板和OV7670摄像头的串口实验,把RGB值通过串口传给电脑,参考了下http://www.openedv.com/posts/list/12583.htm帖子,有些收获,但是为什么串口收不到得到的RGB值呢?换了个例程测试了下串口可以收到数据,但为什么不能接收到RGB值呢?
下面是修改后的源码,大多数参考上面那个帖子:
[size=1em][size=1em][backcolor=rgb(248, 248, 248) !important][color=#a0a0a0 !important]view source[color=#a0a0a0 !important]print[color=#a0a0a0 !important]?
[size=1em][backcolor=rgb(255, 255, 255) !important][size=1em]01 | void camera_refresh(void) |
[backcolor=rgb(248, 248, 248) !important][size=1em]
[backcolor=rgb(255, 255, 255) !important][size=1em]
[backcolor=rgb(248, 248, 248) !important][size=1em]04 | u16 color,color1,color2; |
[backcolor=rgb(255, 255, 255) !important][size=1em]
[backcolor=rgb(248, 248, 248) !important][size=1em]
[backcolor=rgb(255, 255, 255) !important][size=1em]
[backcolor=rgb(248, 248, 248) !important][size=1em]08 | LCD_Scan_Dir(U2D_L2R); //从上到下,从左到右 |
[backcolor=rgb(255, 255, 255) !important][size=1em]09 | LCD_SetCursor(0x00,0x0000); //设置光标位置 |
[backcolor=rgb(248, 248, 248) !important][size=1em]10 | LCD_WriteRAM_Prepare(); //开始写入GRAM |
[backcolor=rgb(255, 255, 255) !important][size=1em]
[backcolor=rgb(248, 248, 248) !important][size=1em]12 | OV7670_RRST=0; //开始复位读指针 |
[backcolor=rgb(255, 255, 255) !important][size=1em]
[backcolor=rgb(248, 248, 248) !important][size=1em]
[backcolor=rgb(255, 255, 255) !important][size=1em]
[backcolor=rgb(248, 248, 248) !important][size=1em]16 | OV7670_RRST=1; //复位读指针结束 |
[backcolor=rgb(255, 255, 255) !important][size=1em]
[backcolor=rgb(248, 248, 248) !important][size=1em]
[backcolor=rgb(255, 255, 255) !important][size=1em]
[backcolor=rgb(248, 248, 248) !important][size=1em]
[backcolor=rgb(255, 255, 255) !important][size=1em]21 | color = GPIOC->IDR&0XFF; //读数据 |
[backcolor=rgb(248, 248, 248) !important][size=1em]
[backcolor=rgb(255, 255, 255) !important][size=1em]
[backcolor=rgb(248, 248, 248) !important][size=1em]
[backcolor=rgb(255, 255, 255) !important][size=1em]
[backcolor=rgb(248, 248, 248) !important][size=1em]26 | color = GPIOC->IDR&0XFF; //读数据 |
[backcolor=rgb(255, 255, 255) !important][size=1em]
[backcolor=rgb(248, 248, 248) !important][size=1em]
[backcolor=rgb(255, 255, 255) !important][size=1em]
[backcolor=rgb(248, 248, 248) !important][size=1em]30 | // printf("%d,",color1); |
[backcolor=rgb(255, 255, 255) !important][size=1em]31 | // printf("%d\n",color2); |
[backcolor=rgb(248, 248, 248) !important][size=1em]
[backcolor=rgb(255, 255, 255) !important][size=1em]33 | g=((color1 &0x07 )<<3 | (color2 & 0xe0 ) >>5 ) << 2; |
[backcolor=rgb(248, 248, 248) !important][size=1em]
[backcolor=rgb(255, 255, 255) !important][size=1em]35 | printf(",%d,%d,%d,\n",r,g,b); |
[backcolor=rgb(248, 248, 248) !important][size=1em]
[backcolor=rgb(255, 255, 255) !important][size=1em]
[backcolor=rgb(248, 248, 248) !important][size=1em]
[backcolor=rgb(255, 255, 255) !important][size=1em]39 | EXTI->PR=1<<8; //清除LINE8上的中断标志位 |
[backcolor=rgb(248, 248, 248) !important][size=1em]
[backcolor=rgb(255, 255, 255) !important][size=1em]
[backcolor=rgb(248, 248, 248) !important][size=1em]42 | // LCD_Scan_Dir(DFT_SCAN_DIR); //恢复默认扫描方向 |
[backcolor=rgb(255, 255, 255) !important][size=1em]
[backcolor=rgb(248, 248, 248) !important][size=1em]
[backcolor=rgb(255, 255, 255) !important][size=1em]
[backcolor=rgb(248, 248, 248) !important][size=1em]
[backcolor=rgb(255, 255, 255) !important][size=1em]47 | u8 lightmode=0,saturation=2,brightness=2,contrast=2; |
[backcolor=rgb(248, 248, 248) !important][size=1em]
[backcolor=rgb(255, 255, 255) !important][size=1em]
[backcolor=rgb(248, 248, 248) !important][size=1em]
[backcolor=rgb(255, 255, 255) !important][size=1em]51 | usmart_dev.init(72); //初始化 |
[backcolor=rgb(248, 248, 248) !important][size=1em]
[backcolor=rgb(255, 255, 255) !important][size=1em]
[backcolor=rgb(248, 248, 248) !important][size=1em]54 | OV7670_Light_Mode(lightmode); |
[backcolor=rgb(255, 255, 255) !important][size=1em]55 | OV7670_Color_Saturation(saturation); |
[backcolor=rgb(248, 248, 248) !important][size=1em]56 | OV7670_Brightness(brightness); |
[backcolor=rgb(255, 255, 255) !important][size=1em]57 | OV7670_Contrast(contrast); |
[backcolor=rgb(248, 248, 248) !important][size=1em]58 | OV7670_Special_Effects(effect); |
[backcolor=rgb(255, 255, 255) !important][size=1em]
[backcolor=rgb(248, 248, 248) !important][size=1em]60 | TIM6_Int_Init(10000,7199); //10Khz计数频率,1秒钟中断 |
[backcolor=rgb(255, 255, 255) !important][size=1em]61 | EXTI8_Init(); //使能定时器捕获 |
[backcolor=rgb(248, 248, 248) !important][size=1em]62 | OV7670_Window_Set(10,174,240,320); //设置窗口 |
[backcolor=rgb(255, 255, 255) !important][size=1em]
[backcolor=rgb(248, 248, 248) !important][size=1em]
[backcolor=rgb(255, 255, 255) !important][size=1em]65 | delay_init(); //延时函数初始化 |
[backcolor=rgb(248, 248, 248) !important][size=1em]66 | NVIC_Configuration(); //设置NVIC中断分组2:2位抢占优先级,2位响应优先级 |
[backcolor=rgb(255, 255, 255) !important][size=1em]67 | uart_init(9600); //串口初始化为9600 |
[backcolor=rgb(248, 248, 248) !important][size=1em]
[backcolor=rgb(255, 255, 255) !important][size=1em]
[backcolor=rgb(248, 248, 248) !important][size=1em]
[backcolor=rgb(255, 255, 255) !important][size=1em]71 | if(USART_RX_STA&0x8000) |
[backcolor=rgb(248, 248, 248) !important][size=1em]
[backcolor=rgb(255, 255, 255) !important][size=1em]73 | len=USART_RX_STA&0x3f;//得到此次接收到的数据长度 |
[backcolor=rgb(248, 248, 248) !important][size=1em]74 | printf("\r\n您发送的消息为:\r\n\r\n"); |
[backcolor=rgb(255, 255, 255) !important][size=1em]
[backcolor=rgb(248, 248, 248) !important][size=1em]
[backcolor=rgb(255, 255, 255) !important][size=1em]77 | USART_SendData(USART1, USART_RX_BUF[t]);//向串口1发送数据 |
[backcolor=rgb(248, 248, 248) !important][size=1em]78 | while(USART_GetFlagStatus(USART1,USART_FLAG_TC)!=SET);//等待发送结束 |
[backcolor=rgb(255, 255, 255) !important][size=1em]
[backcolor=rgb(248, 248, 248) !important][size=1em]
[backcolor=rgb(255, 255, 255) !important][size=1em]
[backcolor=rgb(248, 248, 248) !important][size=1em]
[backcolor=rgb(255, 255, 255) !important][size=1em]
[backcolor=rgb(248, 248, 248) !important][size=1em]
[backcolor=rgb(255, 255, 255) !important][size=1em]85 | printf("请输入数据,以回车键结束\n"); |
[backcolor=rgb(248, 248, 248) !important][size=1em]
[backcolor=rgb(255, 255, 255) !important][size=1em]
[backcolor=rgb(248, 248, 248) !important][size=1em]
[backcolor=rgb(255, 255, 255) !important][size=1em]
[backcolor=rgb(248, 248, 248) !important][size=1em]
[backcolor=rgb(255, 255, 255) !important][size=1em]
|