|
用C8051F340驱动240320 TFT一直不成功,虚拟4线SPI接口,最后发现IO口不受控,初始化以后RST脚电平仍然一直在高低变化,检查接线没问题,请大家帮忙看下什么原因,谢谢
sbit OE = P0^6;
sbit DIR = P0^7;
sbit RST = P3^4;
sbit spi_SDA = P2^0;
sbit spi_SCK = P2^1;
sbit spi_A0 = P3^1;
sbit spi_CS = P3^0;
void main(void)
{
MCU_Init();
LCD_Init();
while(1);
}
void MCU_Init(void)
{
unsigned char n;
PCA0MD &= ~0x40;
//OSC
OSCICN = 0x83; //Internal oscillator enabled, SYSCLK = Internal Oscillator = 12MHz
CLKMUL = 0x00; //Select internal oscillator as clock multiplier source clock
CLKMUL |= 0x80; //Enable clock multiplier
for(n=0;n<255;n++);
CLKMUL |= 0xC0; //Initialize the clock multiplier
while(!(CLKMUL & 0x20)); //Wait for multiplier to lock
CLKSEL = 0x00; //Change SYSCLK to (4x Multiplier ) = 48MHz (48MHz is as fast as F34 will run); 0x03;
RSTSRC |= 0x02;
//P0~P4 //set high impedance , skipped by crossbar
P0MDIN |= 0xFF; //Êý×ÖÊäÈë(ÎÞÄ£ÄâÊäÈ룩
P0MDOUT |= 0xFF; //ÍÆÍìÊä³ö£¨¿ÉÑ¡¿ªÂ©Êä³ö£¬Êä³öÉèΪÍÆÍ죬ÊäÈëÉèΪ¿ªÂ©£©
P1MDOUT |= 0xFF;
P1MDIN &= 0x00;
P2MDIN |= 0xFF;
P2MDOUT |= 0xFF;
P4MDOUT |= 0xFF;
P3MDIN |= 0xFF;
P3MDOUT |= 0xFF; //0001 0111
OE=0;
DIR=1;
//TP_PENIRQ = 1;
//TP_DOUT = 1;
XBR0 |= 0x02;
XBR1 |= 0x40; // Enable Crossbar
}
void LCD_Init(void)
{
//CS0=0;
RST=1;
Delay(100);
RST=0;
Delay(1000);
RST=1;
Delay(1000);
//************* Start Initial Sequence **********//
spi4line_wr_reg(0x11);
Delay(200);
spi4line_wr_reg(0x36);
spi4line_wr_dat(0x00);
spi4line_wr_reg(0x3A);
spi4line_wr_dat(0x55);
spi4line_wr_reg(0xB2);
spi4line_wr_dat(0x0C);
spi4line_wr_dat(0x0C);
spi4line_wr_dat(0x00);
spi4line_wr_dat(0x33);
spi4line_wr_dat(0x33);
spi4line_wr_reg(0xB7);
spi4line_wr_dat(0x35);
spi4line_wr_reg(0xBB);
spi4line_wr_dat(0x2B);
spi4line_wr_reg(0xC0);
spi4line_wr_dat(0x2C);
spi4line_wr_reg(0xC2);
spi4line_wr_dat(0x01);
spi4line_wr_reg(0xC3);
spi4line_wr_dat(0x11);
spi4line_wr_reg(0xC4);
spi4line_wr_dat(0x20);
spi4line_wr_reg(0xC6);
spi4line_wr_dat(0x0F);
spi4line_wr_reg(0xca);
spi4line_wr_dat(0x0f);
spi4line_wr_reg(0xc8);
spi4line_wr_dat(0x08);
spi4line_wr_reg(0x55);
spi4line_wr_dat(0x90);
spi4line_wr_reg(0xD0);
spi4line_wr_dat(0xA4);
spi4line_wr_dat(0xA1);
spi4line_wr_reg(0xE0);
spi4line_wr_dat(0xD0);
spi4line_wr_dat(0x00);
spi4line_wr_dat(0x03);
spi4line_wr_dat(0x09);
spi4line_wr_dat(0x13);
spi4line_wr_dat(0x1C);
spi4line_wr_dat(0x3A);
spi4line_wr_dat(0x55);
spi4line_wr_dat(0x48);
spi4line_wr_dat(0x18);
spi4line_wr_dat(0x12);
spi4line_wr_dat(0x0E);
spi4line_wr_dat(0x19);
spi4line_wr_reg(0xE1);
spi4line_wr_dat(0xD0);
spi4line_wr_dat(0x00);
spi4line_wr_dat(0x03);
spi4line_wr_dat(0x09);
spi4line_wr_dat(0x05);
spi4line_wr_dat(0x25);
spi4line_wr_dat(0x3A);
spi4line_wr_dat(0x55);
spi4line_wr_dat(0x50);
spi4line_wr_dat(0x3D);
spi4line_wr_dat(0x1C);
spi4line_wr_dat(0x1D);
spi4line_wr_dat(0x1D);
spi4line_wr_dat(0x1E);
spi4line_wr_reg(0xB0);
spi4line_wr_dat(0x11);
spi4line_wr_dat(0xc0);
spi4line_wr_reg(0xB1);
spi4line_wr_dat(0x4c);
spi4line_wr_dat(0x02);
spi4line_wr_dat(0x14);
spi4line_wr_reg(0x29);
spi4line_wr_reg(0x2C);
} |
阿莫论坛20周年了!感谢大家的支持与爱护!!
曾经有一段真挚的爱情摆在我的面前,我没有珍惜,现在想起来,还好我没有珍惜……
|