完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
小弟请教过路的高手帮我看看这个程序,买了一个2.0寸的屏,弄了个程序点不亮 。接口是用的4SPI接口的 。
//***********************指令***************************** void write_command (unsigned char y) // (uchar y,uchar x) { unsigned char i; cs=0; rs=0; for(i=0;i<8;i++) { scl=0; if (y&0x80) sdi=1; else sdi=0; scl=1; y=y<<1; } cs=1; } //************************************数据*************************** void write_data(unsigned char w) // (uchar w, uchar v) { unsigned char i; cs=0; rs=1; for(i=0;i<16;i++) { scl=0; if ((w&0x8000)==0x8000) sdi=1; else sdi=0; scl=1; w=w<<1; } cs=1; } /* //*********************************送显示数据 void write_data2(unsigned char data3,unsigned char data4) { unsigned char a,i,b; cs=0; rs=1; a=data3; for(i=0;i<8;i++) { scl=0; if (a&0x80) sdi=1; else sdi=0; scl=1; a=a<<1; } cs=1; cs=0; b=data4; for(i=0;i<8;i++) { scl=0; if (b&0x80) sdi=1; else sdi=0; scl=1; b=b<<1; } cs=1; } */ //*******************color*********************** void display_rgb(unsigned char data1) { unsigned int i,j; write_command(0x22); for(i=0;i<176;i++) for(j=0;j<220;j++) { write_data(data1); } } void initi(void) { res=1; delay(10); res=0; delay(10); res=1; delay(120); write_command(0xd0);write_data(0x0003); // set SS and NL bit write_command(0xeb);write_data(0x0b00); // set 1 line inversion write_command(0xec);write_data(0x000f); // set GRAM write direction and write_command(0xc7);write_data(0x030f); // set GRAM write direction and write_command(0x01);write_data(0x011C); // set SS and NL bit write_command(0x02);write_data(0x0100); // set 1 line inversion write_command(0x03);write_data(0x1030); // write_command(0x07);write_data(0x0000); write_command(0x08);write_data(0x0808); // write_command(0x0F);write_data(0x0601); // write_command(0x10);write_data(0x0A00); // write_command(0x11);write_data(0x1B41); // delay(50); write_command(0x12);write_data(0x200E); // write_command(0x13);write_data(0x0020); // Set GVDD 52 30 write_command(0x14);write_data(0x4A5F); // Set VCOMH/VCOML voltage 5f60 write_command(0x30);write_data(0x0000); write_command(0x31);write_data(0x00DB); write_command(0x32);write_data(0x0000); write_command(0x33);write_data(0x0000); write_command(0x34);write_data(0x00DB); write_command(0x35);write_data(0x0000); write_command(0x36);write_data(0x00AF); write_command(0x37);write_data(0x0000); write_command(0x38);write_data(0x00DB); write_command(0x39);write_data(0x0000); write_command(0x50);write_data(0x0000); write_command(0x51);write_data(0x0803); write_command(0x52);write_data(0x0C07); write_command(0x53);write_data(0x0501); write_command(0x54);write_data(0x070C); write_command(0x55);write_data(0x0308); write_command(0x56);write_data(0x0000); write_command(0x57);write_data(0x0105); write_command(0x58);write_data(0x1100); write_command(0x59);write_data(0x0011); write_command(0x20);write_data(0x0000); // Set GRAM Address write_command(0x21);write_data(0x0000); // Set GRAM Address write_command(0x07);write_data(0x1017); write_command(0x22); } void MCUinit(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 cros***ar P0MDIN |= 0xFF; //数字输入(无模拟输入) P0MDOUT |= 0xFF; //推挽输出(可选开漏输出,输出设为推挽,输入设为开漏) P1MDOUT |= 0xFF; P1MDIN |= 0xFF; P2MDOUT |= 0xFF; P4MDOUT |= 0xFF; P3MDIN |= 0xFF; P3MDOUT |= 0x17; //0001 0111 XBR0 |= 0x02; XBR1 |= 0x40; // Enable Cros***ar } //************************************************************************ void main (void) { MCUinit(); initi(); delay(200); while(1) { display_rgb(0x0000); delay(1000); display_rgb(0xffff); delay(1000); display_rgb(0xf800); delay(1000); display_rgb(0x07e0); delay(1000); } } /*************************************************************************/ |
|
相关推荐
1 个讨论
|
|
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-9-1 14:28 , Processed in 0.606808 second(s), Total 47, Slave 35 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191