cancel
Showing results for 
Search instead for 
Did you mean: 

how would i change this code to it four bit rather than 8?

j g
Associate II
Posted on December 20, 2017 at 14:02

#ifndef _LCD_H_ #define _LCD_H_ #define LCD_PORT GPIOD #define LCD_RS_pin 11 #define LCD_RW_pin 12 #define LCD_E_pin 13 #define LCD_D0_pin 0 #define LCD_LINE1 0x80 #define LCD_LINE2 0xc0 #define set_LCD_RS() LCD_PORT->BSRR=(1u<<lcd_rs_pin) #define='' clr_lcd_rs()='' lcd_port-=''>BSRR=(1u<<(LCD_RS_pin+16)) #define set_LCD_RW() LCD_PORT->BSRR=(1u<<lcd_rw_pin) #define='' clr_lcd_rw()='' lcd_port-=''>BSRR=(1u<<(LCD_RW_pin+16)) #define set_LCD_E() LCD_PORT->BSRR=(1u<<lcd_e_pin) #define='' clr_lcd_e()='' lcd_port-=''>BSRR=(1u<<(LCD_E_pin+16)) #define LCD_CLR() cmdLCD(0x01) #define set_LCD_bus_input() LCD_PORT->MODER&=~(0xffff<<(2*LCD_D0_pin)) #define set_LCD_bus_output() LCD_PORT->MODER|=(0x5555<<(2*LCD_D0_pin)) #include void lcd_delayus(unsigned int us); void WaitLcdBusy(void); void set_LCD_data(unsigned char d); void LCD_strobe(void); void cmdLCD(unsigned char cmd); void putLCD(unsigned char put); void initLCD(void); #endif

1 REPLY 1
john doe
Lead
Posted on December 21, 2017 at 12:57

Please reformat your post so it is legible.

uint8_t byte; // your 8 bit number

do4bitStuff(byte >> 4);  //high nibble

do4bitStuff(byte); // low nibble

Also, consider reading the HD44780 data sheet.