⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 c8051f330_camera.lst

📁 OV7670模组带转接板资料
💻 LST
📖 第 1 页 / 共 3 页
字号:
C51 COMPILER V9.00   C8051F330_CAMERA                                                      09/22/2012 14:17:10 PAGE 1   


C51 COMPILER V9.00, COMPILATION OF MODULE C8051F330_CAMERA
OBJECT MODULE PLACED IN .\obj\c8051f330_camera.obj
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE source\c8051f330_camera.c BROWSE INCDIR(.\inc) DEBUG OBJECTEXTEND PRINT(.\o
                    -bj\c8051f330_camera.lst) OBJECT(.\obj\c8051f330_camera.obj)

line level    source

   1          /*******************************************************************************
   2          *  Copyright (C) 2010 - All Rights Reserved
   3          *               
   4          * 软件作者:     骑飞家族
   5          * 版权所有: 骑飞电子    
   6          * 创建日期:     2010年6月10日 
   7          * 软件历史:     2010年11月2日修改
   8          * Version:  1.0 
   9          * Demo 淘宝地址:http://store.taobao.com/shop/view_shop.htm?asker=wangwang&shop_nick=qifeidianzi
  10          **********************************************************************************************************
             -************************************
  11          懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒
             -懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒
  12          懒懒懒懒懒懒懒懒懒懒懒一懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒困一懒懒懒懒懒懒懒懒懒懒
             -懒懒懒懒一一一一一一一懒懒懒懒懒懒懒
  13          懒懒困一一一一懒一一一一一一二懒懒懒懒困一一一一一一一一懒懒懒懒懒懒懒懒懒四厲懒懒一一懒懒懒一懒懒懒懒懒懒
             -懒懒懒一一一一四四一一一懒懒懒懒懒懒
  14          懒懒懒懒懒懒一懒懒懒一二一懒懒懒懒懒懒一一一一四厲二一四懒一一懒懒懒懒懒四一一一一一一一一一一一懒懒懒懒懒
             -懒懒懒四懒懒四一一一一厲懒懒懒懒懒懒
  15          懒懒懒四厲厲一懒懒厲懒懒懒四懒懒懒懒懒懒懒懒懒懒懒困一懒一一懒懒懒懒懒懒懒一一厲厲一一厲厲厲一一懒懒懒懒懒
             -懒厲厲厲厲厲厲一一厲厲厲懒懒懒懒懒懒
  16          懒懒懒一懒二一一一一一一一一一一一懒懒懒懒懒懒懒懒二一一困懒懒懒懒懒懒懒懒一一一一一一一一一一四懒懒懒懒懒
             -一一一一一一一一一一一一一一一懒懒懒
  17          懒懒懒一一一一一厲二一一厲一懒厲懒懒懒懒懒懒懒懒懒一一一一一懒懒懒懒懒懒懒一一懒懒一一懒懒懒一困懒懒懒懒懒
             -一一四懒懒懒懒一一懒懒困一一四懒懒懒
  18          懒懒懒懒懒懒懒一困一懒一厲一懒懒懒懒懒懒懒懒懒懒懒困一懒懒一一懒懒懒懒懒懒一一一一一一一一一一厲懒懒懒懒懒
             -懒懒懒懒懒懒懒一一厲懒懒懒懒懒懒懒懒
  19          懒二一一一懒四困厲一一一厲一懒懒懒懒懒懒懒懒懒懒懒懒一一懒懒懒懒懒懒懒懒懒懒懒懒懒四一厲懒懒懒懒懒懒一懒懒
             -懒懒懒懒懒懒懒一一厲懒懒懒懒懒懒懒懒
  20          懒懒懒懒懒懒一懒懒懒懒懒一一懒懒懒懒懒懒懒懒懒懒懒懒厲一一一一一一困懒懒懒懒懒懒懒懒一一一一一一一一一懒懒
             -懒懒懒困懒懒厲一一懒懒懒懒懒懒懒懒懒
  21          懒懒懒懒一一一懒懒困一一一一懒懒懒懒懒懒懒懒懒懒懒懒懒懒一一一一一懒懒懒懒懒懒懒懒懒懒一一一一一一一懒懒懒
             -懒懒懒懒一一一一四懒懒懒懒懒懒懒懒懒
  22          懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒
             -懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒懒
  23          **********************************************************************************************************
             -************************************/
  24          #include <c8051f330.h>
  25          #include <english_16x8.h>
  26          
  27          ///////////////////////////////////////////////////////
  28          #define BLACK   0x0000
  29          #define BLUE    0x001F
  30          #define RED     0xF800
  31          #define GREEN   0x07E0
  32          #define CYAN    0x07FF
  33          #define MAGENTA 0xF81F
  34          #define YELLOW  0xFFE0
  35          #define WHITE   0xFFFF          
  36          
  37          #define AM          001
  38          #define TIME               100
  39          
  40          #define SDA_IN()                {P0MDOUT= 0X00;}
C51 COMPILER V9.00   C8051F330_CAMERA                                                      09/22/2012 14:17:10 PAGE 2   

  41          #define SDA_OUT()               {P0MDOUT= 0XFF;}
  42          
  43          
  44          //Tft control lines
  45          sbit Tft_RS_PIN=P0^6;
  46          sbit Tft_WR_PIN=P0^7;
  47          sbit Tft_RST_PIN=P0^4;
  48          
  49          //camera control lines
  50          sbit I2C_SCL=P0^1;
  51          sbit I2C_SDA=P0^0;
  52          sbit Cmos_VSYNC=P0^5;
  53          sbit SDA_STATE=P0^0;
  54          
  55          //sn74lvc245 control lines
  56          sbit Cmos_CS_PIN=P0^2;
  57          
  58          //SN74LVC1G125 CONTROL LINES
  59          sbit WR_CONTROL_PIN=P0^3;
  60          
  61          void OSCILLATOR_Init (void);
  62          void Port_Init(void);
  63          void Ext_Interrupt_Init (void);
  64          
  65          void Tft_Init(void);
  66          void TftClear(unsigned int Color);
  67          void Tft_WR_DATA16(unsigned int inputdata);
  68          void TftWrite16(unsigned int index);
  69          void TftWrite(unsigned int index,unsigned int inputdata);
  70          void TftWR_Str(unsigned int x,unsigned int y,unsigned char *s,unsigned int color,unsigned int xcolor);
  71          void TftWR_SingleStr(unsigned char inputdata,unsigned int color,unsigned int xcolor);
  72          void Tft_SetBackground(unsigned int StartX,unsigned int StartY,unsigned int LongX,unsigned int LongY);
  73          void Tft_SetCursor(unsigned int Xpos, unsigned int Ypos);
  74          
  75          unsigned char WrCmos7670(unsigned char regID, unsigned char regDat);
  76          unsigned char Cmos7670_init(void);
  77          void set_Cmos7670reg(void);
  78          
  79          void delay_us(unsigned int time);
  80          void delay_ms(unsigned int time);
  81          void delay( unsigned long cnt);
  82          
  83          ///////////////////////////////////////////
  84          void DelayI2C(void);
  85          void InitI2C(void);
  86          void StartI2C(void);
  87          void StopI2C(void);
  88          void NoAck(void);
  89          unsigned char I2CWrite(unsigned char DData);
  90          ////////////////////////////////////////////
  91          unsigned int flag;
  92          ///////////////////////////////////////////
  93          
  94          void main(void)
  95          {
  96   1              PCA0MD &= ~0x40;                       
  97   1              OSCILLATOR_Init ();
  98   1              Port_Init();
  99   1              Ext_Interrupt_Init( );
 100   1              WR_CONTROL_PIN=1;
 101   1              Tft_Init( );    
 102   1              TftClear(BLACK);
C51 COMPILER V9.00   C8051F330_CAMERA                                                      09/22/2012 14:17:10 PAGE 3   

 103   1              TftWR_Str(60,70,"C8051F330 Camera",RED,BLACK);
 104   1              TftWR_Str(60,100,"QI FEI DIAN ZI VER1.0",RED,BLACK);    
 105   1              TftWR_Str(60,130,"OV7670 Initializing......",RED,BLACK);
 106   1              delay_ms(3000);
 107   1      
 108   1              while(1!=Cmos7670_init());
 109   1              delay_ms(3000);
 110   1              TftClear(BLACK);
 111   1              TftWR_Str(60,110,"OV7670  Init  SUCCESS!  ",RED,BLACK);
 112   1              delay_ms(5000);
 113   1      
 114   1              TftClear(BLACK); 
 115   1              EA = 1;
 116   1              while(1);
 117   1              
 118   1        
 119   1      }
 120          
 121          
 122          
 123          void OSCILLATOR_Init (void)
 124          {
 125   1          OSCICN  = 0x83; 
 126   1              RSTSRC =        0x04;                
 127   1      }
 128          
 129          
 130          void Port_Init(void)
 131          {
 132   1              
 133   1              P0MDIN = 0xFF;
 134   1              P1MDIN = 0XFF;
 135   1      
 136   1              P0MDOUT= 0XFF;
 137   1              P1MDOUT= 0XFF;
 138   1       
 139   1              P0SKIP = 0X00;
 140   1              P1SKIP = 0X00;
 141   1      
 142   1          XBR0   = 0x00;
 143   1          XBR1   = 0x40;
 144   1      
 145   1      
 146   1      }
 147          
 148          
 149          
 150          void Ext_Interrupt_Init (void)    
 151          {
 152   1          IT01CF    = 0x0d;
 153   1              IT0=1;
 154   1          IE        = 0x01;
 155   1      }
 156          
 157          
 158          void INT0_ISR (void) interrupt 0  
 159          {
 160   1      
 161   1              EA=0;
 162   1              IE0=0; 
 163   1      
 164   1              P0MDOUT= 0xff;
C51 COMPILER V9.00   C8051F330_CAMERA                                                      09/22/2012 14:17:10 PAGE 4   

 165   1              WR_CONTROL_PIN=1;
 166   1              Cmos_CS_PIN=1;
 167   1      
 168   1              TftWrite(0x0020,0x0000);
 169   1              TftWrite(0x0021,0x013f); 
 170   1              TftWrite(0x0050,0x00);
 171   1              TftWrite(0x0051,239);
 172   1              TftWrite(0x0052,0x00);
 173   1              TftWrite(0x0053,319);
 174   1              TftWrite(0x0003,0x1018);
 175   1              TftWrite16(0x0022);
 176   1      
 177   1      
 178   1              Tft_RS_PIN=1;
 179   1              Tft_WR_PIN=0;
 180   1      
 181   1      
 182   1              WR_CONTROL_PIN=0;
 183   1              Cmos_CS_PIN=0;
 184   1       
 185   1              EA=1;
 186   1      
 187   1      }
 188          
 189          void Tft_Init(void)
 190          {
 191   1                      
 192   1              Tft_RST_PIN=1;
 193   1              delay_ms(10);; 
 194   1              Tft_RST_PIN=0;
 195   1              delay_ms(10);
 196   1              Tft_RST_PIN=1;
 197   1              delay_ms(150);
 198   1      
 199   1      
 200   1                      TftWrite(0x00e5, 0x8000);       
 201   1                      TftWrite(0x0000, 0x0001);       
 202   1                      TftWrite(0x0001, 0x0100);
 203   1                      TftWrite(0x0002, 0x0700);
 204   1              #if AM==000       
                              TftWrite(0x0003,0x1000);
                      #elif AM==001        
 207   1                      TftWrite(0x0003,0x1008);      
 208   1              #elif AM==010  
                          TftWrite(0x0003,0x1010);        
                      #elif AM==011
                              TftWrite(0x0003,0x1018);
                      #elif AM==100  
                              TftWrite(0x0003,0x1020);      
                      #elif AM==101  
                              TftWrite(0x0003,0x1028);      
                      #elif AM==110  
                              TftWrite(0x0003,0x1030);      
                      #elif AM==111  
                              TftWrite(0x0003,0x1038);
                      #endif
 221   1                      TftWrite(0x0004, 0x0000);
 222   1                      TftWrite(0x0008, 0x0202);       
 223   1                      TftWrite(0x0009, 0x0000);       
 224   1                      TftWrite(0x000A, 0x0000);
 225   1                      TftWrite(0x000C, 0x0000);       
 226   1                      TftWrite(0x000D, 0x0000);       
C51 COMPILER V9.00   C8051F330_CAMERA                                                      09/22/2012 14:17:10 PAGE 5   

 227   1                      TftWrite(0x000F, 0x0000);       
 228   1                      TftWrite(0x0010, 0x0000);       
 229   1                      TftWrite(0x0011, 0x0007);       
 230   1                      TftWrite(0x0012, 0x0000);       
 231   1                      TftWrite(0x0013, 0x0000);       
 232   1                      delay_ms(1000);
 233   1                      TftWrite(0x0010, 0x17B0);       
 234   1                      TftWrite(0x0011, 0x0007);       
 235   1                      delay_ms(1000);
 236   1                      TftWrite(0x0012, 0x013A);       
 237   1                      delay_ms(1000);
 238   1                      TftWrite(0x0013, 0x1A00);       
 239   1                      TftWrite(0x0029, 0x000c);               
 240   1                      delay_ms(1000);
 241   1                      TftWrite(0x0030, 0x0000);       
 242   1                      TftWrite(0x0031, 0x0505);       
 243   1                      TftWrite(0x0032, 0x0004);       
 244   1                      TftWrite(0x0035, 0x0006);       
 245   1                      TftWrite(0x0036, 0x0707);       
 246   1                      TftWrite(0x0037, 0x0105);       
 247   1                      TftWrite(0x0038, 0x0002);       
 248   1                      TftWrite(0x0039, 0x0707);       
 249   1                      TftWrite(0x003C, 0x0704);       
 250   1                      TftWrite(0x003D, 0x0807);       
 251   1                      TftWrite(0x0050, 0x0000);
 252   1                      TftWrite(0x0051, 0x00EF);
 253   1                      TftWrite(0x0052, 0x0000);
 254   1                      TftWrite(0x0053, 0x013F);
 255   1                      TftWrite(0x0060, 0x2700);
 256   1                      TftWrite(0x0061, 0x0001);
 257   1                      TftWrite(0x006A, 0x0000);
 258   1              #if AM==000         
                              TftWrite(0x0020,0x00ef);
                              TftWrite(0x0021,0x013f);      

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -