1385 views|0 replies

1140

Posts

0

Resources
The OP
 

Ov7670 image acquisition source program based on TINYM0 LPC1114 [Copy link]

After a month of preparation and two weeks of program debugging, the application of TINYM0 development board (LPC1114 chip) was realized. The image was collected by OV7670 with FIFO image acquisition module and displayed on the LCD screen driven by ili9325. The experimental program transplanted the image acquisition program of Zhengdian Atom STM32. During the debugging process, it was found that the LCD screen and OV7670 shared the data line, resulting in the screen distortion phenomenon. It has not been solved yet, so the shared port method was not used. (For the specific configuration of the port, see the LCD and OV7670 initialization part). The microcontroller source program is as follows: /******************************************************************/ /* Name: OV7670 image acquisition and display program*/ /* Author: Li Ying*/ /* ccutchi */ /* Welcome to learn*/ /**********************************************************************/ #include "nxplpc11xx.h" #include "ili9325.h" #include "w25x16.h" #include "gui.h" #include "xpt2046.h" #include "delay.h" #include "ov7670.h" #include "gui.h" extern uint8_t ov_sta; //Frame Number of times to set the flag void EXTI2_Init(void); //Update LCD display void camera_refresh(void) { uint32_t j; uint16_t color,temp_color; if(ov_sta==2) //Judge whether the camera data is stored in the buffer { OV7670_RRST_0; //Start resetting the read pointer OV7670_RCK_0; OV7670_RCK_1; OV7670_RCK_0; OV7670_RRST_1; //End of resetting the read pointer OV7670_RCK_1; OV7670_CS_L; //fif open for(j=0;j<76800;j++) //The resolution is 240x320. Each color point requires two bytes, so 240x320x2=76800 times { // GPIO2->DIR &=0x00F; // Set the high 8-bit pin of P2 port as input, used as OV76708-bit parallel data input // GPIO2->DATA = 0XFF0; // Set the high 8-bit pin of P2 port high OV7670_RCK_0; //Read data once for each clock jump color=GPIO0->DATA&0X1FE; //color=GPIOC->IDR&0XFF; //P0.0~P0.8 Read data Read color high byte data OV7670_RCK_1; color<<=7; //Left shift 8 bits to move the high byte to the high 8 bits to prepare for receiving the low 8 bits temp_color=color; OV7670_RCK_0; color=GPIO0->DATA&0X1FE; //color=GPIOC->IDR&0XFF; //Read data Read color low byte data OV7670_RCK_1; color>>=1; color|=temp_color; LCD_WR_DATA(color); } GPIO1->IC = 0x3FF; // Clear the interrupt on GPIO1 ov_sta=0; // Start the next acquisition } } /* unsigned int Image_Buffer; unsigned char Image[104][14];//Image array unsigned int OrgRow=0,OrgColumn=0;//Set the initial values of rows and columns unsigned int sampleRow=0,samleColumn=0;//Set the initial value of the row and column unsigned int sampleRow_Max=239,samleColumn_Max=239;//Set the maximum value of the initial value of the row and column void ImagePlay(void);//Image display function void ImageProcess(void);//Image processing function void AutoControl(void);//Control function void OV5116_INIT(void); */ int main(void) { //uint8_t lightmode=0,saturation=2,brightness=2,contrast=2; //uint8_t effect=0; SysCLK_config(); // Clock configuration SCCB_Init(); LCD_Init(); // LCD initialization SCCB_Start(); while(OV7670_Init())//Initialize OV7670 { Draw_TextBox(20, 20, 100, 100); } //The camera parameter settings are shielded to the default effect OV7670_Light_Mode(0);//lightmode OV7670_Color_Saturation(2);//saturation OV7670_Brightness(2);//brightness OV7670_Contrast(2);//contrast OV7670_Special_Effects(0); //effect OV7670_Window_Set(10,174,240,320); //Set window //OV7670_CS_L; //Enable camera chip select EXTI2_Init(); //Initialize interrupt line LCD_Clear(BLUE); //Full screen display white while(1) { camera_refresh(); } } void EXTI2_Init(void) { SYSCON->SYSAHBCLKCTRL |= (1<<16); // Enable IOCON clock (bit16) IOCON->PIO1_0 = 0XD1; // Set PIN33 to P1.0 pin SYSCON->SYSAHBCLKCTRL &= ~(1<<16); // Disable IOCON clock (bit16) // Set P1.0 and P1.1 as input GPIO1->DIR &= ~(1<<0); GPIO1->DATA |= (1<<0); GPIO1->IS &= ~(1<<0); // Select P1.0 as edge triggered GPIO1->IEV |=(1<<0);//Select P1.0 as rising edge trigger GPIO1->IE |= (1<<0); //Set P1.0 interrupt not to be masked NVIC_EnableIRQ(EINT1_IRQn); // Enable GPIO1 interrupt } //GPIO1 interrupt service function void PIOINT1_IRQHandler(void) { if((GPIO1->MIS&0x001)==0x001) // Check if it is an interrupt generated by P1.0 pin { if(ov_sta<2) { if(ov_sta==0) { OV7670_WRST_L;//=0; //Reset the write pointer OV7670_WRST_H;//=1; OV7670_WREN_H;//=1; //Allow writing to FIFO } else { // OV7670_WRST_L;//=0; //Reset the write pointer // OV7670_WRST_H;//=1; OV7670_WREN_L;//=0; //Disable writing to FIFO } ov_sta++; } GPIO1->IC = 0x3FF; // Clear the interrupt on GPIO1 } }Interrupt generated by pin 0 { if(ov_sta<2) { if(ov_sta==0) { OV7670_WRST_L; //=0; //Reset write pointer OV7670_WRST_H; //=1; OV7670_WREN_H; //=1; //Allow writing to FIFO } else { // OV7670_WRST_L; //=0; //Reset write pointer // OV7670_WRST_H;//=1; OV7670_WREN_L;//=0; //Disable writing to FIFO } ov_sta++; } GPIO1->IC = 0x3FF; // Clear interrupt on GPIO1 } }


This post is from Microcontroller MCU
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list