找回密码
 注册
搜索
查看: 1111|回复: 1

[讨论] M0直接驱动OV7725,出现图像问题

[复制链接]
发表于 2015-3-12 21:00:07 | 显示全部楼层 |阅读模式
用M0配置OV7725 ,然后sensor数据直接给TFT显示!图像只看到发光的物体,而且偏绿~~~弄了三天找不出原因,发上来请大家帮帮忙!

下面是OV7725配置
const  char change_reg[CHANGE_REG_NUM][2]=
{       
  /*òÔÏÂÎaOV7725QVGA RGB5652Îêy*/

  {0x32,0x00},
  {0x2a,0x00},
  {0x11,0x01},
  {0x12,0x46},//QVGA RGB565
  {0x12,0x46},

  {0x42,0x7f},
  {0x4d,0x00},//0x09
  {0x63,0xf0},
  {0x64,0xff},
  {0x65,0x20},
  {0x66,0x00},
  {0x67,0x00},
  {0x69,0x5d},  

  {0x13,0xff},
  {0x0d,0x41},//PLL
  {0x0f,0xc5},
  {0x14,0x11},
  {0x22,0xff},//7f
  {0x23,0x03},
  {0x24,0x34},
  {0x25,0x3c},
  {0x26,0xa1},
  {0x2b,0x00},
  {0x6b,0xaa},
  {0x13,0xff},

  {0x90,0x0a},//
  {0x91,0x01},//
  {0x92,0x01},//
  {0x93,0x01},
  
  {0x94,0x5f},
  {0x95,0x53},
  {0x96,0x11},
  {0x97,0x1a},
  {0x98,0x3d},
  {0x99,0x5a},
  {0x9a,0x1e},
  
  {0x9b,0x28},//set luma
  {0x9c,0x25},//set contrast
  {0xa7,0x65},//set saturation  
  {0xa8,0x65},//set saturation
  {0xa9,0x80},//set hue
  {0xaa,0x80},//set hue
        {0xab,0x06},//set luma
  
  {0x9e,0x81},
  {0xa6,0x06},

  {0x7e,0x0c},
  {0x7f,0x16},
  {0x80,0x2a},
  {0x81,0x4e},
  {0x82,0x61},
  {0x83,0x6f},
  {0x84,0x7b},
  {0x85,0x86},
  {0x86,0x8e},
  {0x87,0x97},
  {0x88,0xa4},
  {0x89,0xaf},
  {0x8a,0xc5},
  {0x8b,0xd7},
  {0x8c,0xe8},
  {0x8d,0x20},

  {0x33,0x00},
  {0x22,0x99},
  {0x23,0x03},
  {0x4a,0x00},
  {0x49,0x13},
  {0x47,0x08},
  {0x4b,0x14},
  {0x4c,0x17},
  {0x46,0x05},
  {0x0e,0x75},
  {0x0c,0x50},
  {0x00,0xf0},
  {0x29,0x50},
  {0x2C,0x78},


};



这是TFT的配置
void LCD_WR_DATA16(uint16_t data)//D′»y′æÆ÷êy¾Y
{
     LCD_RD_H();
     LCD_RS_H();
     LCD_CS_L();
     
      GPIOA->ODR=(GPIOA->ODR&0XFF00)| (uint8_t )(data>>8);
     LCD_WR_L();
     LCD_WR_H();

     GPIOA->ODR=(GPIOA->ODR&0XFF00)|(uint8_t )data;     
     LCD_WR_L();
     LCD_WR_H();
     
     LCD_CS_H();
  
}
void LCD_WR_REG16(uint16_t index)//D′»y′æÆ÷Ãüáî
{
     LCD_RD_H();
     LCD_RS_L();
     LCD_CS_L();
     
     GPIOA->ODR=(GPIOA->ODR&0XFF00)| (uint8_t )(index>>8);
     LCD_WR_L();
     LCD_WR_H();

     GPIOA->ODR=(GPIOA->ODR&0XFF00)|(uint8_t )index;     
     LCD_WR_L();
     LCD_WR_H();
     
     LCD_CS_H();
}
uint16_t LCD_RD_DATA16(void)//¶á»y′æÆ÷êy¾Y
{
     uint16_t data;
     LCD_WR_H();
     LCD_RS_H();
     LCD_GPIO_INPUT();
     LCD_CS_L();

     LCD_RD_L();
     
     LCD_RD_H();
     data=(0x00ff&DATA_LCD_PIN);
     data=data<<8;
     
         
     LCD_RD_L();
     
     LCD_RD_H();
     data|=(0x00ff&DATA_LCD_PIN);
     
     LCD_CS_H();
     LCD_GPIO_OUTPUT();
     return data;
  
}
void LCD_WR_REG(uint16_t index,uint16_t data)
{
     LCD_WR_REG16(index);
     LCD_WR_DATA16(data);
}


void LCD_Init(void)
{   
        LCD_GPIO_OUTPUT();
        LCD_Set_GPIO_Config();
//        LCD_BL_L();
        LCD_RST_H();
        delay_ms(500);
        
        CMOS_CS_H();
        PCLK_ON_L();
        
        LCD_RST_L();
        delay_ms(1000);
        LCD_RST_H();
        
     
//        LCD_WR_REG(0x00E3,0x3008);        
//        LCD_WR_REG(0x00E7,0x0012);
//        LCD_WR_REG(0x00Ef,0x1231);         // Set the internal timing;  
     LCD_WR_REG(0x00E5,0x8000);   
        //initializing funciton 1
         LCD_WR_REG(0x00,0x0001);
         LCD_WR_REG(0x01, 0x0000); // set SS and SM bit
         LCD_WR_REG(0x02, 0x0700); // set 1 line inversion
        // LCD_WR_REG(0x03, 0x10B0); // set GRAM write direction and BGR=1.
#if   ID_AM==000      
             LCD_WR_REG(0x0003,0x1000);//&#198;á&#196;&#187;Dy×a&#191;&#216;&#214;&#198; TFM=0,TRI=0,SWAP=1,16 bits system interface  swap RGB to BRG£&#172;′&#203;′|ORGoíHWM &#206;a0
#elif ID_AM==001        
             LCD_WR_REG(0x0003,0x1008);      
#elif ID_AM==010  
             LCD_WR_REG(0x0003,0x1010);        
#elif ID_AM==011
             LCD_WR_REG(0x0003,0x1018);
#elif ID_AM==100  
             LCD_WR_REG(0x0003,0x1020);      
#elif ID_AM==101  
             LCD_WR_REG(0x0003,0x1028);      
#elif ID_AM==110  
             LCD_WR_REG(0x0003,0x1030);      
#elif ID_AM==111  
             LCD_WR_REG(0x0003,0x1038);
#endif   
         LCD_WR_REG(0x04, 0x0000); // Resize register
         LCD_WR_REG(0x08, 0x0404); // set the back porch and front porch
         LCD_WR_REG(0x09, 0x0000); // set non-display area refresh cycle ISC[3:0]
         LCD_WR_REG(0x0A, 0x0000); // FMARK function
        // LCD_WR_REG(0x0C, 0x0000); // RGB interface setting
        // LCD_WR_REG(0x0D, 0x0000); // Frame marker Position
        // LCD_WR_REG(0x0F, 0x0000); // RGB interface polarity
//Power On sequence //
         LCD_WR_REG(0x10, 0x0000); // SAP, BT[3:0], AP, DSTB, SLP, STB
         LCD_WR_REG(0x11, 0x0007); // DC1[2:0], DC0[2:0], VC[2:0]
         LCD_WR_REG(0x12, 0x0000); // VREG1OUT voltage
         LCD_WR_REG(0x13, 0x0000); // VDV[4:0] for VCOM amplitude
//         LCD_WR_REG(0x07, 0x0001); //
                 
         delay_ms(1000); // Dis-charge capacitor power voltage
         
         LCD_WR_REG(0x10, 0x17B0); // SAP, BT[3:0], AP, DSTB, SLP, STB
         LCD_WR_REG(0x11, 0x0007); // DC1[2:0], DC0[2:0], VC[2:0]
         delay_ms(1000); // Delay 50ms
        
         LCD_WR_REG(0x12, 0x013a); // Internal reference voltage= Vci;
         delay_ms(1000); // Delay 50ms
         LCD_WR_REG(0x13, 0x1a00); // Set VDV[4:0] for VCOM amplitude
         LCD_WR_REG(0x29, 0x000C); // Set VCM[5:0] for VCOMH
//         LCD_WR_REG(0x2B, 0x000f); // Set Frame Rate
         delay_ms(1000); // Delay 50ms
         
#if   ID_AM==000         
             LCD_WR_REG(0x0020,0x00ef);//GRAM&#203;&#174;&#198;&#189;&#198;eê&#188;&#206;&#187;&#214;&#195;
             LCD_WR_REG(0x0021,0x013f);      
#elif ID_AM==001
             LCD_WR_REG(0x0020,0x00ef);
             LCD_WR_REG(0x0021,0x013f);      
#elif ID_AM==010
             LCD_WR_REG(0x0020,0x0000);
             LCD_WR_REG(0x0021,0x013f);      
#elif ID_AM==011
             LCD_WR_REG(0x0020,0x0000);
             LCD_WR_REG(0x0021,0x013f);      
#elif ID_AM==100
             LCD_WR_REG(0x0020,0x00ef);
             LCD_WR_REG(0x0021,0x0000);      
#elif ID_AM==101  
             LCD_WR_REG(0x0020,0x00ef);
             LCD_WR_REG(0x0021,0x0000);      
#elif ID_AM==110
             LCD_WR_REG(0x0020,0x0000);
             LCD_WR_REG(0x0021,0x0000);      
#elif ID_AM==111
             LCD_WR_REG(0x0020,0x0000);
             LCD_WR_REG(0x0021,0x0000);         
#endif  
// ----------- Adjust the Gamma Curve ----------//
                LCD_WR_REG(0x0030,0x0000);
                LCD_WR_REG(0x0031,0x0505);
                LCD_WR_REG(0x0032,0x0004);
                LCD_WR_REG(0x0035,0x0006);
                LCD_WR_REG(0x0036,0x0707);
                LCD_WR_REG(0x0037,0x0105);
                LCD_WR_REG(0x0038,0x0002);
                LCD_WR_REG(0x0039,0x0707);
                LCD_WR_REG(0x003C,0x0704);
                LCD_WR_REG(0x003D,0x0807);
//------------------ Set GRAM area ---------------//
         LCD_WR_REG(0x0050, 0x0000); // Horizontal GRAM Start Address
         LCD_WR_REG(0x0051, 0x00EF); // Horizontal GRAM End Address
         LCD_WR_REG(0x0052, 0x0000); // Vertical GRAM Start Address
         LCD_WR_REG(0x0053, 0x013F); // Vertical GRAM Start Address
         LCD_WR_REG(0x0060, 0x2700); // Gate Scan Line
         LCD_WR_REG(0x0061, 0x0001); // NDL,VLE, REV
         LCD_WR_REG(0x006A, 0x0000); // set scrolling line
//-------------- Partial Display Control ---------//
         LCD_WR_REG(0x80, 0x0000);
         LCD_WR_REG(0x81, 0x0000);
         LCD_WR_REG(0x82, 0x0000);
         LCD_WR_REG(0x83, 0x0000);
         LCD_WR_REG(0x84, 0x0000);
         LCD_WR_REG(0x85, 0x0000);
//-------------- Panel Control -------------------//
         LCD_WR_REG(0x90, 0x0010);
         LCD_WR_REG(0x92, 0x0000);
         LCD_WR_REG(0x93, 0x0003);
         LCD_WR_REG(0x95, 0x0110);
         LCD_WR_REG(0x97, 0x0000);
         LCD_WR_REG(0x98, 0x0000);
         LCD_WR_REG(0x07, 0x0173); // 262K color and display ON   0133
         LCD_Clear(0x0000);
         delay_ms(1000); // Delay 5ms

              //  LCD_Clear(0x001f);
        // CMOS_CS_L();
        // PCLK_ON_H();
  
}



发表于 2015-3-20 18:17:11 | 显示全部楼层
嘻嘻,我们家有OV7725.qq 1399858837
点评回复

使用道具 举报

高级模式
B Color Image Link Quote Code Smilies

本版积分规则

Archiver|手机版|小黑屋|52RD我爱研发网 ( 沪ICP备2022007804号-2 )

GMT+8, 2024-4-20 12:41 , Processed in 0.046123 second(s), 16 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表