新手上路
- 积分
- 45
- 金钱
- 45
- 注册时间
- 2015-1-30
- 在线时间
- 0 小时
|
楼主 |
发表于 2015-2-2 09:38:28
|
显示全部楼层
回复【5楼】正点原子:
---------------------------------
整个初始化代码是这样的
void LCD_init(void)
{
uint16_t id=0;
GPIO_Init( GPIOG,GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3|\
GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7,GPIO_MODE_OUT_PP_HIGH_FAST) ;
/*16位数据高8位*/
GPIO_Init( GPIOB,GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3|\
GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7,GPIO_MODE_OUT_PP_HIGH_FAST) ;
/*控制脚*/
GPIO_Init( GPIOD,GPIO_PIN_3|GPIO_PIN_2|GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7,GPIO_MODE_OUT_PP_HIGH_FAST) ;
// 设置PB口低8位引脚为输出,用作LCD16位并行数据和控制引脚
GPIOB->DDR|=0xFF;
GPIOB->ODR &=0x00; // B口低8位引脚置低
// 设置PC口低8位引脚为输出,用作LCD16位并行数据和控制引脚
GPIOG->DDR|=0xFF;
GPIOG->ODR &=0x00; // C口低8位引脚置低
GPIOD->DDR&=0xc8;
GPIOD->DDR|=0x37;
GPIOD->ODR&=0xc8;
GPIO_RST();
#if 0
//LCD_WR_REG_DATA(0x0000,0x0001);
Delay(100); // delay 50 ms
//id = LCD_RD_REG_DATA(0x0000);
//Delay(100); // delay 50 ms
LCD_WR_REG(0x00d3);
id = LCD_RD_DATA();
//UART_send_byte(id);
id = LCD_RD_DATA();
//UART_send_byte(id);
//UART_send_byte(id>>8);
id = LCD_RD_DATA();
UART_send_byte(id);
id = LCD_RD_DATA();
UART_send_byte(id);
#endif
#if 1
//ILI9327,BOE3.0
//************* Start Initial Sequence **********//
LCD_WR_REG(0x00CF);
LCD_WR_DATA(0x0000);
LCD_WR_DATA(0x00C1);
LCD_WR_DATA(0X0030);
LCD_WR_REG(0x00ED);
LCD_WR_DATA(0x0064);
LCD_WR_DATA(0x0003);
LCD_WR_DATA(0X0012);
LCD_WR_DATA(0X0081);
LCD_WR_REG(0x00E8);
LCD_WR_DATA(0x0085);
LCD_WR_DATA(0x0010);
LCD_WR_DATA(0x007A);
LCD_WR_REG(0x00CB);
LCD_WR_DATA(0x0039);
LCD_WR_DATA(0x002C);
LCD_WR_DATA(0x0000);
LCD_WR_DATA(0x0034);
LCD_WR_DATA(0x0002);
LCD_WR_REG(0x00F7);
LCD_WR_DATA(0x0020);
LCD_WR_REG(0x00EA);
LCD_WR_DATA(0x0000);
LCD_WR_DATA(0x0000);
LCD_WR_REG(0x00C0); //Power control
LCD_WR_DATA(0x0021); //VRH[5:0]
//LCD_WR_DATA(0x1B); //VRH[5:0]
LCD_WR_REG(0x00C1); //Power control
LCD_WR_DATA(0x0013); //SAP[2:0];BT[3:0]
//LCD_WR_DATA(0x01); //SAP[2:0];BT[3:0]
LCD_WR_REG(0x00C5); //VCM control
LCD_WR_DATA(0x003F);
LCD_WR_DATA(0x003C);
//LCD_WR_DATA(0x30);
//LCD_WR_DATA(0x30);
LCD_WR_REG(0x00C7); //VCM control2
LCD_WR_DATA(0X00AE);
//LCD_WR_DATA(0xB7);
LCD_WR_REG(0x0036); // Memory Access Control
LCD_WR_DATA(0x0008);
//LCD_WR_DATA(0x48); //C8 //48 68竖屏//28 E8 横屏
LCD_WR_REG(0x003A);
LCD_WR_DATA(0x0055);
LCD_WR_REG(0x00B1);
LCD_WR_DATA(0x0000);
LCD_WR_DATA(0x0016);
//LCD_WR_DATA(0x1A);
LCD_WR_REG(0x00B6); // Display Function Control
LCD_WR_DATA(0x000A);
LCD_WR_DATA(0x00A2);
LCD_WR_REG(0x00F6);
LCD_WR_DATA(0x0001);
LCD_WR_DATA(0x0030);
LCD_WR_REG(0x00F2); // 3Gamma Function Disable
LCD_WR_DATA(0x0000);
LCD_WR_REG(0x0026); //Gamma curve selected
LCD_WR_DATA(0x0001);
LCD_WR_REG(0x002B);
LCD_WR_DATA(0x0000);
LCD_WR_DATA(0x0000);
LCD_WR_DATA(0x0001);
LCD_WR_DATA(0x003f);
LCD_WR_REG(0x002A);
LCD_WR_DATA(0x0000);
LCD_WR_DATA(0x0000);
LCD_WR_DATA(0x0000);
LCD_WR_DATA(0x00ef);
LCD_WR_REG(0x0011); //Exit Sleep
Delay(240);
LCD_WR_REG(0x0029); //Display on
} |
|