The LCD panel model:LM6060CBY
I want to use the gpio port initialization LCD pin,but i don't know why is the LCD screen is couldn't show Chinese characters, don't know whether I drive call errors, hope everybody to help me look at it.
Below is the LCD initialization code:
void initLCDM(void)
{
uint8_t ContrastLevel=0x2c; // default Contrast Level
GPIO_DRV_Init(NULL,lcdpins);//gpio initialization :GPIO_DRV_Init(const gpio_input_pin_user_config_t * inputPins,const gpio_output_pin_user_config_t * outputPins)
configure_lcd_pins(0);//gpio Pin reuse
GPIO_DRV_WritePinOutput(kLCDCS, 1);
GPIO_DRV_WritePinOutput(kLCDRST,1);
GPIO_DRV_WritePinOutput(kLCDA0, 1);
GPIO_DRV_WritePinOutput(kLCDWR, 1);
GPIO_DRV_WritePinOutput(kLCDRD, 1);
GPIO_DRV_WritePinOutput(kLCDD0, 1);
GPIO_DRV_WritePinOutput(kLCDD1, 1);
GPIO_DRV_WritePinOutput(kLCDD2, 1);
GPIO_DRV_WritePinOutput(kLCDD3, 1);
GPIO_DRV_WritePinOutput(kLCDD4, 1);
GPIO_DRV_WritePinOutput(kLCDD5, 1);
GPIO_DRV_WritePinOutput(kLCDD6, 1);
GPIO_DRV_WritePinOutput(kLCDD7, 1);
GPIO_DRV_WritePinOutput(kLCDVC, 1);
GPIO_DRV_WritePinOutput(kLCDVD, 1);
GPIO_DRV_WritePinOutput(kLCDRST, 1);
GPIO_DRV_WritePinOutput(kLCDRST, 0);
GPIO_DRV_WritePinOutput(kLCDRST, 1);
SdCmd(0xaf); // display on
SdCmd(0x40); // display start line=0
SdCmd(0xa0); // ADC=0
SdCmd(0xa6); // normal display
SdCmd(0xa4); // Duisplay all point = off
SdCmd(0xa2); // LCD bias = 1/9
SdCmd(0xc8); // Common output mode select= reverse
SdCmd(0x2f); // Power control = all on
SdCmd(0x25); // LCD(G-mode) use internal Rb/Ra;
/********************Modify booster multiple f801(5x)->f800***********/
SdCmd(0xf8); // Booster Ratio = 4x
SdCmd(0x00); // (two byte command)
/********************************************************************/
SdCmd(0x81); // E-Vol setting
SdCmd(ContrastLevel); // (2byte command)
Display_Clear();
}
const gpio_output_pin_user_config_t lcdpins[] = {
{
.pinName = kLCDCS,
.config.outputLogic = 0,
.config.slewRate = kPortFastSlewRate,
.config.driveStrength = kPortHighDriveStrength,
//.config.interrupt = kPortIntDisabled,
},
{
.pinName = kLCDRST,
.config.outputLogic = 0,
.config.slewRate = kPortFastSlewRate,
.config.driveStrength = kPortHighDriveStrength,
},
{
.pinName = kLCDA0,
.config.outputLogic = 0,
.config.slewRate = kPortFastSlewRate,
.config.driveStrength = kPortHighDriveStrength,
},
{
.pinName = kLCDWR,
.config.outputLogic = 0,
.config.slewRate = kPortFastSlewRate,
.config.driveStrength = kPortHighDriveStrength,
},
{
.pinName = kLCDRD,
.config.outputLogic = 0,
.config.slewRate = kPortFastSlewRate,
.config.driveStrength = kPortHighDriveStrength,
},
{
.pinName = kLCDD0,
.config.outputLogic = 0,
.config.slewRate = kPortFastSlewRate,
.config.driveStrength = kPortHighDriveStrength,
},
{
.pinName = kLCDD1,
.config.outputLogic = 0,
.config.slewRate = kPortFastSlewRate,
.config.driveStrength = kPortHighDriveStrength,
},
{
.pinName = kLCDD2,
.config.outputLogic = 0,
.config.slewRate = kPortFastSlewRate,
.config.driveStrength = kPortHighDriveStrength,
},
{
.pinName = kLCDD3,
.config.outputLogic = 0,
.config.slewRate = kPortFastSlewRate,
.config.driveStrength = kPortHighDriveStrength,
},
{
.pinName = kLCDD4,
.config.outputLogic = 0,
.config.slewRate = kPortFastSlewRate,
.config.driveStrength = kPortHighDriveStrength,
},
{
.pinName = kLCDD5,
.config.outputLogic = 0,
.config.slewRate = kPortFastSlewRate,
.config.driveStrength = kPortHighDriveStrength,
},
{
.pinName = kLCDD6,
.config.outputLogic = 0,
.config.slewRate = kPortFastSlewRate,
.config.driveStrength = kPortHighDriveStrength,
},
{
.pinName = kLCDD7,
.config.outputLogic = 0,
.config.slewRate = kPortFastSlewRate,
.config.driveStrength = kPortHighDriveStrength,
},
{
.pinName = kLCDVC,
.config.outputLogic = 0,
.config.slewRate = kPortFastSlewRate,
.config.driveStrength = kPortHighDriveStrength,
},
{
.pinName = kLCDVD,
.config.outputLogic = 0,
.config.slewRate = kPortFastSlewRate,
.config.driveStrength = kPortHighDriveStrength,
},
{
.pinName = GPIO_PINS_OUT_OF_RANGE,
}
};
//lcdÒý½Å¸´ÓÃ
void configure_lcd_pins(uint32_t instance)
{
PORT_HAL_SetMuxMode(PORTB_BASE,18U,kPortMuxAsGpio);
PORT_HAL_SetMuxMode(PORTC_BASE,16U,kPortMuxAsGpio);
PORT_HAL_SetMuxMode(PORTB_BASE,19U,kPortMuxAsGpio);
PORT_HAL_SetMuxMode(PORTC_BASE,17U,kPortMuxAsGpio);
PORT_HAL_SetMuxMode(PORTC_BASE,1U,kPortMuxAsGpio);
PORT_HAL_SetMuxMode(PORTB_BASE,9U,kPortMuxAsGpio);
PORT_HAL_SetMuxMode(PORTC_BASE,8U,kPortMuxAsGpio);
PORT_HAL_SetMuxMode(PORTA_BASE,1U,kPortMuxAsGpio);
PORT_HAL_SetMuxMode(PORTC_BASE,9U,kPortMuxAsGpio);
PORT_HAL_SetMuxMode(PORTB_BASE,23U,kPortMuxAsGpio);
PORT_HAL_SetMuxMode(PORTC_BASE,0U,kPortMuxAsGpio);
PORT_HAL_SetMuxMode(PORTA_BASE,2U,kPortMuxAsGpio);
PORT_HAL_SetMuxMode(PORTC_BASE,7U,kPortMuxAsGpio);
PORT_HAL_SetMuxMode(PORTC_BASE,2U,kPortMuxAsGpio);
PORT_HAL_SetMuxMode(PORTC_BASE,5U,kPortMuxAsGpio);
}
//write 12864LCD command
void SdCmd(uint8_t Command) //send command
{
GPIO_DRV_WritePinOutput(kLCDA0, 0);
GPIO_DRV_WritePinOutput(kLCDWR, 1);
GPIO_DRV_WritePinOutput(kLCDRD, 1);
if((Command & 0x01) ==0)
GPIO_DRV_WritePinOutput(kLCDD0, 0);
else
GPIO_DRV_WritePinOutput(kLCDD0, 1);
if((Command & 0x02) ==0)
GPIO_DRV_WritePinOutput(kLCDD1, 0);
else
GPIO_DRV_WritePinOutput(kLCDD1, 1);
if((Command & 0x04) ==0)
GPIO_DRV_WritePinOutput(kLCDD2, 0);
else
GPIO_DRV_WritePinOutput(kLCDD2, 1);
if((Command & 0x08) ==0)
GPIO_DRV_WritePinOutput(kLCDD3, 0);
else
GPIO_DRV_WritePinOutput(kLCDD3, 1);
if((Command & 0x10) ==0)
GPIO_DRV_WritePinOutput(kLCDD4, 0);
else
GPIO_DRV_WritePinOutput(kLCDD4, 1);
if((Command & 0x20) ==0)
GPIO_DRV_WritePinOutput(kLCDD5, 0);
else
GPIO_DRV_WritePinOutput(kLCDD5, 1);
if((Command & 0x40) ==0)
GPIO_DRV_WritePinOutput(kLCDD6, 0);
else
GPIO_DRV_WritePinOutput(kLCDD6, 1);
if((Command & 0x80) ==0)
GPIO_DRV_WritePinOutput(kLCDD7, 0);
else
GPIO_DRV_WritePinOutput(kLCDD7, 1);
GPIO_DRV_WritePinOutput(kLCDCS, 0);
GPIO_DRV_WritePinOutput(kLCDWR, 0);
GPIO_DRV_WritePinOutput(kLCDWR, 1);
GPIO_DRV_WritePinOutput(kLCDCS, 1);
}
//send data
void SdData(uint8_t DData)
{
GPIO_DRV_WritePinOutput(kLCDA0, 1);
GPIO_DRV_WritePinOutput(kLCDWR, 1);
GPIO_DRV_WritePinOutput(kLCDRD, 1);
if((DData & 0x01) ==0)
GPIO_DRV_WritePinOutput(kLCDD0, 0);
else
GPIO_DRV_WritePinOutput(kLCDD0, 1);
if((DData & 0x02) ==0)
GPIO_DRV_WritePinOutput(kLCDD1, 0);
else
GPIO_DRV_WritePinOutput(kLCDD1, 1);
if((DData & 0x04) ==0)
GPIO_DRV_WritePinOutput(kLCDD2, 0);
else
GPIO_DRV_WritePinOutput(kLCDD2, 1);
if((DData & 0x08) ==0)
GPIO_DRV_WritePinOutput(kLCDD3, 0);
else
GPIO_DRV_WritePinOutput(kLCDD3, 1);
if((DData & 0x10) ==0)
GPIO_DRV_WritePinOutput(kLCDD4, 0);
else
GPIO_DRV_WritePinOutput(kLCDD4, 1);
if((DData & 0x20) ==0)
GPIO_DRV_WritePinOutput(kLCDD5, 0);
else
GPIO_DRV_WritePinOutput(kLCDD5, 1);
if((DData & 0x40) ==0)
GPIO_DRV_WritePinOutput(kLCDD6, 0);
else
GPIO_DRV_WritePinOutput(kLCDD6, 1);
if((DData & 0x80) ==0)
GPIO_DRV_WritePinOutput(kLCDD7, 0);
else
GPIO_DRV_WritePinOutput(kLCDD7, 1);
GPIO_DRV_WritePinOutput(kLCDCS, 0);
GPIO_DRV_WritePinOutput(kLCDWR, 0);
GPIO_DRV_WritePinOutput(kLCDWR, 1);
GPIO_DRV_WritePinOutput(kLCDCS, 1);
}
//display
void Display_ASCII(uint8_t Font,uint8_t Nor_Inv_Cur,uint8_t Char, uint8_t X, uint8_t Y)
{
uint16_t ASCII_Index;
uint8_t row; //ÐÐ
uint8_t Addr_Page,column_low, column_hight;
uint8_t k;
Addr_Page=0;
k=0;
if(Font == 1)
{
ASCII_Index=(Char-0x20)<<4;
Addr_Page=X|0xb0;
column_hight=((Y>>1)&0x0F)|0x10;
column_low=(Y<<3)&0x0F;
SdCmd(Addr_Page); //ÉÏ°ëÒ³
SdCmd(column_hight);
SdCmd(column_low);
for (row=0; row<8; row++)
{
k=chardot_8x16[ASCII_Index++];
if(Nor_Inv_Cur==1)k=~k;
SdData(k);
}
SdCmd(Addr_Page+1); //Ï°ëÒ³
SdCmd(column_hight); //µ÷ÊԵ㣬ÊÇ·ñÐèÒªÖØÉècolumn£¬Ò²¼´¿ÉÖªµÀcolumn address counterÊÇ·ñ×Ô¼º×ÔÔö
SdCmd(column_low);
for (row=8; row<16; row++)
{
k=chardot_8x16[ASCII_Index++];
if(Nor_Inv_Cur==1)k=~k;
SdData(k);
}
}
else //En_5x8 5x8×Ö¿â¸ñʽÐè¸Ä
{
ASCII_Index=(Char-0x20)*5;
Addr_Page=X|0xb0;
column_hight=((Y>>1)&0x0F)|0x10;
column_low=(Y<<3)&0x0F;
SdCmd(Addr_Page);
SdCmd(column_hight);
SdCmd(column_low);
for (row=0; row<5; row++)SdData(chardot_5x8[ASCII_Index++]);
// for (row=0; row<5; row++)SdData(0x00);
}
}
int main (void)
{
OSA_Init(); /* Init uC/OS-II. */
initLCDM();
Display_ASCII(1,0,0x36,4,2); |
OSA_Start(); /* Start multitasking (i.e. give control to uC/OS-II). */
while (DEF_ON) { /* Should Never Get Here */
;
}
}