void initLCD(void){ GPIO_DeInit(LCD_PORT); GPIO_Init(LCD_PORT, GPIO_PIN_ALL, GPIO_MODE_OUT_PP_LOW_FAST); GPIO_WriteLow(LCD_PORT,LCD_E); //clear enable GPIO_WriteLow(LCD_PORT,LCD_RS); //going to write command DelayMS(30); //delay for LCD to initialise. LCD_NYB(0x03,0); //Required for initialisation DelayMS(5); //required delay LCD_NYB(0x03,0); //Required for initialisation DelayMS(1); //required delay LCD_DATA(0x02,0); //set to 4 bit interface, 1 line and 5*7 font LCD_DATA(0x28,0); //set to 4 bit interface, 2 line and 5*10 font LCD_DATA(0x0c,0); //set to 4 bit interface, 2 line and 5*7 font LCD_DATA(0x01,0); //clear display LCD_DATA(0x06,0); //move cursor right after write }
void LCD_Init(void){ //Setai pini pt LCD LCD_PORT->MODER = 0x5055; //Setaea pinilo pentu output PD0:PD3(DB4:DB7),PD6(E),PD7(RS) LCD_PORT->OTYPER = 0x00; //Setae de tip PUSH-PULL pentu toti LCD_PORT->OSPEEDR = 0xA0AA; //50 MHz Fecventa potului pentu LCD LCD_PORT->PUPDR = 0x00; //PULL-UP/PULL-DOWN Dezactivate BitClr(LCD_E); //clear enable - pin PD6 BitClr(LCD_RS); //going to write command - pin PD7 DelayMS(30); //delay for LCD to initialise. LCD_NYB(0x30,0); //Required for initialisation DelayMS(5); //required delay LCD_NYB(0x30,0); //Required for initialisation DelayMS(1); //required delay LCD_DATA(0x02,0); //set to 4 bit interface, 1 line and 5*7 font LCD_DATA(0x28,0); //set to 4 bit interface, 2 line and 5*10 font LCD_DATA(0x0c,0); //set to 4 bit interface, 2 line and 5*7 font LCD_DATA(0x01,0); //clear display LCD_DATA(0x06,0); //move cursor right after write }
//--------------------------------------------------------------------------------// void LCD_DATA(unsigned char data,unsigned char type){ WaitLCDBusy(); //TEST LCD FOR BUSY if(type == CMD){ BitClr(LCD_RS); //COMMAND MODE } else { BitSet(LCD_RS); //CHARACTER/DATA MODE } LCD_NYB(data>>4,type); //WRITE THE UPPER NIBBLE LCD_NYB(data,type); //WRITE THE LOWER NIBBLE }
void LCD_DATA(unsigned char data,unsigned char type){ DelayMS(10); //TEST LCD FOR BUSY LCD_NYB(data>>4,type); //WRITE THE UPPER NIBBLE LCD_NYB(data,type); //WRITE THE LOWER NIBBLE }