测试色带是正常的平整的,如图所示
摄像头端
void ov7670()//单片机读取OV7670的图片像素并发送到TFT屏幕上
{
uint8_t sendData[5]; // 假设数组长度为5个字节
while(OV7670_VS()==0){};
OV7670_W_WRST(0);
OV7670_W_WRST(1);
OV7670_W_WEN(1);
Delay_us(40000);
while(OV7670_VS()==0);
OV7670_W_WRST(0);
OV7670_W_WRST(1);
OV7670_W_WEN(0);
Delay_us(50000);
OV7670_W_OE(0);
OV7670_W_RRST(0);
OV7670_W_RCLK(0);
Delay_us(20000);
OV7670_W_RCLK(1);
Delay_us(20000);
OV7670_W_RCLK(0);
Delay_us(20000);
OV7670_W_RRST(1);
Delay_us(20000);
OV7670_W_RCLK(1);
// set_windows(0,0,lcddev.width-1,lcddev.height-1);
for(h=0;h<160;h++)//128
{
// printf("------1--------\n");
for(w=0;w<128;w++)
{
OV7670_W_RCLK(0);
// 读取 PA15, PB3~PB9 引脚状态
uint8_t PA15_state = (GPIOA->IDR >> 15) & 0x01;
uint8_t PB3_state = (GPIOB->IDR >> 3) & 0x01;
uint8_t PB4_state = (GPIOB->IDR >> 4) & 0x01;
uint8_t PB5_state = (GPIOB->IDR >> 5) & 0x01;
uint8_t PB6_state = (GPIOB->IDR >> 6) & 0x01;
uint8_t PB7_state = (GPIOB->IDR >> 7) & 0x01;
uint8_t PB8_state = (GPIOB->IDR >> 8) & 0x01;
uint8_t PB9_state = (GPIOB->IDR >> 9) & 0x01;
value1 = (uint8_t)((PA15_state << 7) | (PB9_state << 6) | (PB8_state << 5) | (PB7_state << 4) | (PB6_state << 3) | (PB5_state << 2) | (PB4_state << 1) | PB3_state);
// printf("v1=%d\n",value1);
OV7670_W_RCLK(1);
OV7670_W_RCLK(0);
PA15_state = (GPIOA->IDR >> 15) & 0x01;
PB3_state = (GPIOB->IDR >> 3) & 0x01;
PB4_state = (GPIOB->IDR >> 4) & 0x01;
PB5_state = (GPIOB->IDR >> 5) & 0x01;
PB6_state = (GPIOB->IDR >> 6) & 0x01;
PB7_state = (GPIOB->IDR >> 7) & 0x01;
PB8_state = (GPIOB->IDR >> 8) & 0x01;
PB9_state = (GPIOB->IDR >> 9) & 0x01;
value2 = (uint8_t)((PA15_state << 7) | (PB9_state << 6) | (PB8_state << 5) | (PB7_state << 4) | (PB6_state << 3) | (PB5_state << 2) | (PB4_state << 1) | PB3_state);
// printf("v2=%d\n",value2);
OV7670_W_RCLK(1);
color = value1 << 8 | value2;
// color = color | value2;
//// printf("color=%d\n",color);
// TFT_WRITE_uint16_t_DATA(color);
sendData[4] = 1;
sendData[3] = w ;
sendData[2] = h ;
sendData[0] = value1; // 获取 color 的高 8 位
sendData[1] = value2; // 获取 color 的高 8 位
// printf("------2--------\n");
// printf("v1=%d,v2=%d\n",value1,value2);
printf("w=%d,H=%d,color1=%d,color2=%d\n",sendData[3],sendData[2],sendData[0],sendData[1]);
HAL_UART_Transmit_DMA(&huart2, sendData, sizeof(sendData));
}
}
OV7670_W_OE(1);
}
lcd端串口接收中断
if (huart == &huart2)
{
printf("2\n");
uint16_t color = (uint16_t) sendData[0] << 8;
color |= (uint16_t)sendData[1];
LCD_DrawPoint((uu16)sendData[3],(uu16)sendData[2],color);
}
[*附件:CS_LCD.zip](//file1.elecfans.com/web2/M00/07/27/wKgaombjCKyALQ21AX4uYeDWbOw675.zip)
[*附件:CS_SXT-3.zip](//file1.elecfans.com/web2/M00/07/27/wKgaombjCUmAcLNfAGdLsN9w2Nw837.zip)
更多回帖