|
前段時間開始搞TFT的屏,用了一段時間就發現初始化好了,后面就跟12864的差不多了,最多改一下寄存器.
現在顯示部分跟觸摸屏都搞好了,開始弄攝像頭,發現老是卡在一個地方了,所以上來求助了.
我是參照:http://www.ourdev.cn/bbs/bbs_content.jsp?bbs_sn=3401782&bbs_page_no=1&search_mode=1&search_text=ov7660&bbs_id=1000
這個貼子做的,就是修改了一下IO口.
//============================== Read ov7660 register ==================================
uchar ReadOV7660A(uchar reg, uchar *data)
{
//========== Set register ==========
StartSCCB();
if(0 == SCCBWriteChar(0x42))
{
StopSCCB();
TFTWriteStringH(3,0,"Why1",YELLOW,BLACK);
return 0;
}
NOACK();
//DelaySCCB();
if(0 == SCCBWriteChar(reg))
{
StopSCCB();
TFTWriteStringH(3,0,"Why2",YELLOW,BLACK);
return 0;
}
StopSCCB();
NOACK();
//DelaySCCB();
//========== Read from register ==========
StartSCCB();
if(0 == SCCBWriteChar(0x43))
{
StopSCCB();
TFTWriteStringH(3,0,"Why3",YELLOW,BLACK);
return 0;
}
DelaySCCB();
*data = SCCBReadChar();
NOACK();
StopSCCB();
return 1;
}
就是卡在TFTWriteStringH(3,0,"Why3",YELLOW,BLACK);這里.
這段函數是在OV7660初始化調用的.
//============================== OV7660 initialize =====================================
uchar OV7660Init(void)
{
uchar temp = 0x80,i;
uchar msb = 0,lsb = 0;
InitSCCB();
if(WriteOV7660(0x12,temp) == 0) //Reset SCCB
{
return 0;
}
_delay_ms(250);
ReadOV7660A(0x0a,&msb);
if(msb != 0x76) //Why not msb = 0x76
{
TFTWriteStringH(3,1,"MSB is incorrect",YELLOW,BLACK);
return 0;
}
ReadOV7660A(0x0b,&lsb);
if(lsb != 0x60) //Why not lsb = 0x60
{
TFTWriteStringH(3,2,"LSB is incorrect",YELLOW,BLACK);
return 0;
}
for(i=0;i<14;i ++)
{
if(WriteOV7660(change_reg[0],change_reg[1]) == 0)
{
return 0;
}
}
TFTWriteStringH(3,3,"Config now......",YELLOW,BLACK);
OV7660Config(272,16,320,240); //Set 320 * 240
_delay_ms(250);
_delay_ms(250);
TFTWriteChar(3,4,"OV7660 Initial OK!",YELLOW,BLACK);
return 0x01;
}
發現初始化里面的msb和lsb老是不對,然后對了接線沒發現問題,msb和lsb每次都不一樣,原來沒讀到ov7660的.
搞了兩天沒搞好.求各位大大幫下.... |
阿莫论坛20周年了!感谢大家的支持与爱护!!
曾经有一段真挚的爱情摆在我的面前,我没有珍惜,现在想起来,还好我没有珍惜……
|