We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I'm using the LCD_4bits project to display data (MCBSTM32 board) but when I change the LCD with another (phico d-0 94v-0) "">www.datasheetarchive.com/LM2780A2C40HN-datasheet.html" i can't display data. I need to change the pin assignement in order to use the 8bits-mode. can you help me.
It seems that you don't want to help me
we gladly will; HOWEVER to do it by providing another program for 8bits mode would not be help, but doing your job for you.
show YOUR code and help will be forthcoming.
Erik
thanks Erik. this the lcd_8bits.c
/**********************************************************************/ /* Includes ------*/ #include "lcd.h" #include "stm32f10x_conf.h" #include "stm32f10x.h" #include "LCD_8bits.h" /* Private functions ----------*/ /******************************* * Function Name : LCD_Init * Description : Initialisation routine for Alphanumeric Display. * Input param : NONE * Return : None ******************************/ void LCD_Init(void) { /*Start First Line Of LCD*/ WriteCommand(START_ONE); /*Start Second Line Of LCD*/ WriteCommand(START_TWO); /*function set-2 line display, 5*7 dots format display mode*/ WriteCommand(FUNCTION_SET); /*Display off*/ WriteCommand(DISPLAY_OFF); /*Display on,cursor off,cursor blink off*/ WriteCommand(DISPLAY_SETTINGS); /*Entry mode set-Increment and no display shift*/ WriteCommand(ENTRY_MODESET); /*clear display*/ WriteCommand(CLR_DISPLAY); /*Return home Command, sets the cursor at the beginning of the first line*/ WriteCommand(RETURN_HOME); } /*********************************** * Function Name : WriteCommand * Description : Writes a command to the LCD * Input param : u8_Command i.e the command to be sent to LCD * Return : None ************************************/ void WriteCommand( u8 u8_Command) { u8 u8_Cmd; u16 u16_TempVar=0; /*take RS low for Command*/ RESET_RS; //GPIO_WriteBit(GPIOA, GPIO_Pin_12, Bit_RESET); u8_Cmd =u8_Command; /*This retains the value of RS and Enable while sending the Command to the data pins*/ u16_TempVar=u16_TempVar | (u16)u8_Cmd; /********************For port C*******************/ if( (u16_TempVar) & (DATA_LINE_0) ) { GPIO_WriteBit(GPIOA, GPIO_Pin_1, Bit_SET); } else { GPIO_WriteBit(GPIOA, GPIO_Pin_1, Bit_RESET); }
if( (u16_TempVar) & (DATA_LINE_1) ) { GPIO_WriteBit(GPIOA, GPIO_Pin_2, Bit_SET); } else { GPIO_WriteBit(GPIOA, GPIO_Pin_2, Bit_RESET); } /****************For port D***********************/ if( (u16_TempVar) & (DATA_LINE_2) ) { GPIO_WriteBit(GPIOA, GPIO_Pin_3, Bit_SET); } else { GPIO_WriteBit(GPIOA, GPIO_Pin_3, Bit_RESET); } /*******************For port B**********************/ if( (u16_TempVar) & (DATA_LINE_3) ) { GPIO_WriteBit(GPIOA, GPIO_Pin_4, Bit_SET); } else { GPIO_WriteBit(GPIOA, GPIO_Pin_4, Bit_RESET); }
if( (u16_TempVar) & (DATA_LINE_4) ) { GPIO_WriteBit(GPIOA, GPIO_Pin_5, Bit_SET); } else { GPIO_WriteBit(GPIOA, GPIO_Pin_5, Bit_RESET); }
if( (u16_TempVar) & (DATA_LINE_5) ) { GPIO_WriteBit(GPIOA, GPIO_Pin_6, Bit_SET); } else { GPIO_WriteBit(GPIOA, GPIO_Pin_6, Bit_RESET); }
if( (u16_TempVar) & (DATA_LINE_6) ) { GPIO_WriteBit(GPIOA, GPIO_Pin_7, Bit_SET); } else { GPIO_WriteBit(GPIOA, GPIO_Pin_7, Bit_RESET); }
if( (u16_TempVar) & (DATA_LINE_7) ) { GPIO_WriteBit(GPIOA, GPIO_Pin_8, Bit_SET); } else { GPIO_WriteBit(GPIOA, GPIO_Pin_8, Bit_RESET); } /*****************************************/ /* take E high to enable data to be send to the LCD*/ SET_ENABLE; Delay(MS_ONE); //ST1208S_Delay(10,210); /*takes E low*/ RESET_ENABLE; Delay(MS_ONE); //ST1208S_Delay(10,210); } /********************************** * Function Name : WriteData * Description : Writes a data to the LCD * Input param : u8_Data i.e the data to be written on LCD * Return : None ***************************************/ void WriteData(u8 u8_Data) { u8 u8_Data1; /*Take RS high for data*/ RESET_RW; SET_RS; //GPIO_WriteBit(GPIOA, GPIO_Pin_12, Bit_SET); u8_Data1=u8_Data; /*This retains the value of RS and Enable while sending the data to the data pins*/ /**********************For port C********************/ if( (u8_Data1) & (DATA_LINE_0) ) { GPIO_WriteBit(GPIOA, GPIO_Pin_1, Bit_SET); } else { GPIO_WriteBit(GPIOA, GPIO_Pin_1, Bit_RESET); }
if( (u8_Data1) & (DATA_LINE_1) ) { GPIO_WriteBit(GPIOA, GPIO_Pin_2, Bit_SET); } else { GPIO_WriteBit(GPIOA, GPIO_Pin_2, Bit_RESET); }
/********************************For port D*********************************/ if( (u8_Data1) & (DATA_LINE_2) ) { GPIO_WriteBit(GPIOA, GPIO_Pin_3, Bit_SET); } else { GPIO_WriteBit(GPIOA, GPIO_Pin_3, Bit_RESET); } /*********************For port B******************/ if( (u8_Data1) & (DATA_LINE_3) ) { GPIO_WriteBit(GPIOA, GPIO_Pin_4, Bit_SET); } else { GPIO_WriteBit(GPIOA, GPIO_Pin_4, Bit_RESET); }
if( (u8_Data1) & (DATA_LINE_4) ) { GPIO_WriteBit(GPIOA, GPIO_Pin_5, Bit_SET); } else { GPIO_WriteBit(GPIOA, GPIO_Pin_5, Bit_RESET); }
if( (u8_Data1) & (DATA_LINE_5) ) { GPIO_WriteBit(GPIOA, GPIO_Pin_6, Bit_SET); } else { GPIO_WriteBit(GPIOA, GPIO_Pin_6, Bit_RESET); }
if( (u8_Data1) & (DATA_LINE_6) ) { GPIO_WriteBit(GPIOA, GPIO_Pin_7, Bit_SET); } else { GPIO_WriteBit(GPIOA, GPIO_Pin_7, Bit_RESET); }
if( (u8_Data1) & (DATA_LINE_7) ) { GPIO_WriteBit(GPIOA, GPIO_Pin_8, Bit_SET); } else { GPIO_WriteBit(GPIOA, GPIO_Pin_8, Bit_RESET); } /****************************/ /*take E high*/ SET_ENABLE; Delay(MS_ONE); //ST1208S_Delay(10,210); /*take E low*/ RESET_ENABLE; Delay(MS_ONE); //ST1208S_Delay(10,210); } /****************************** * Function Name : ChangeLine * Description : Puts the cursor on 1st position of line 1 or 2 by * setting DDRAM address * Input param : line number * Return : None ********************************/ void ChangeLine(u8 u8_line) { switch(u8_line) { case 1:WriteCommand(LINEONE_HOME);/*address of the 1st position of 1st line*/ break; case 2:WriteCommand(LINETWO_HOME);/*address of the 1st position of 2nd line*/ break; } } /*************************************** * Function Name : WriteString * Description : writes the string to the LCD * Input param : pointer to character string * Return : None ****************************/ void WriteString(u8 *pu8_StringForLCD) { while(*pu8_StringForLCD!='\0') { WriteData(*pu8_StringForLCD); pu8_StringForLCD++; } } /****************************************** * Function Name : ClrDisplay * Description : Clear the display of LCD * Input param : NONE * Return : NONE ***********************************/ void ClrDisplay(void) { /*take RS low for sending Command*/ RESET_RS; Delay(MS_ONE); //ST1208S_Delay(10,210); WriteCommand(CLR_DISPLAY); Delay(MS_ONE); //ST1208S_Delay(10,210);
} /******************************/
and this the lcd_8bits.h
/*****************************/ /* Includes --------------------*/ //#include "stm32f10x_type.h" #include "stm32f10x_gpio.h" /* Macro Definitions ----------*/ #define SET_RS (GPIO_WriteBit(GPIOC, GPIO_Pin_2, Bit_SET)); #define RESET_RS (GPIO_WriteBit(GPIOC, GPIO_Pin_2, Bit_RESET)); #define SET_ENABLE (GPIO_WriteBit(GPIOC, GPIO_Pin_10, Bit_SET)); #define RESET_ENABLE (GPIO_WriteBit(GPIOC, GPIO_Pin_10, Bit_RESET)); #define SET_RW (GPIO_WriteBit(GPIOC, GPIO_Pin_9, Bit_SET)); #define RESET_RW (GPIO_WriteBit(GPIOC, GPIO_Pin_9, Bit_RESET)); /* private define-----------------*/ #define LINEONE (1)// line one of 16X2 alphanumeric display #define LINETWO (2)// line two of 16X2 alphanumeric display #define LINETWO_HOME (0xc0) #define LINEONE_HOME (0x80) #define START_ONE (0x33) #define START_TWO (0x32) #define FUNCTION_SET (0x38) #define DISPLAY_OFF (0x08) #define DISPLAY_SETTINGS (0x0E) #define ENTRY_MODESET (0x06) #define CLR_DISPLAY (0x01) #define RETURN_HOME (0x02) #define MS_FIVE (0x0032) #define MS_FIFTEEN (0x0096) #define MS_EIGHTY (0x0320) #define VH_OnTime (0x0015) #define VH_OffTime (0x0004) #define FIVE_SEC (0xC350) #define MS_ONE (0x000A) #define ONE_SEC (0x2710) #define TWO_SEC (0x4E20) #define TEN_MILLI_SEC (0x0064) #define MS_P19 (0x0019) /*data line defination-----------------*/ #define DATA_LINE_0 (0x0001) #define DATA_LINE_1 (0x0002) #define DATA_LINE_2 (0x0004) #define DATA_LINE_3 (0x0008) #define DATA_LINE_4 (0x0010) #define DATA_LINE_5 (0x0020) #define DATA_LINE_6 (0x0040) #define DATA_LINE_7 (0x0080) /* Exported functions ---------------- */ /* LCD functions */ void LCD_Init(void); void ClrDisplay(void); void WriteCommand(u8); void WriteData(u8); void ChangeLine(u8); void WriteString(u8 *); void Delay(u32); //-----------
I'am using MCBSTM32 board and an lcd (phico d-0 94v-0).