Hello everyone. I have a code for lcd alphanumeric and using a lm3s328 . I am using the driverlib of stelaris , but when I send something to print , nothing appears . Below follows the codes Thank you .
//LCD.H #include "../device/lm3s_cmsis.h" #include "../driverlib/sysctl.h" #include "../driverlib/gpio.h" #ifndef LCD_H_ #define LCD_H_ #define LCD_PORT_ENABLE SYSCTL_PERIPH_GPIOB #define LCD_PORT GPIO_PORTB_BASE #define LCD_D4 GPIO_PIN_0 #define LCD_D5 GPIO_PIN_1 #define LCD_D6 GPIO_PIN_2 #define LCD_D7 GPIO_PIN_3 #define LCD_RS GPIO_PIN_4 #define LCD_EN GPIO_PIN_5 //.......// #endif /* LCD_H_ */
//LCD.C #include "../device/lm3s_cmsis.h" #include "../drivers/displays/lcdLPC/lcdLPC.h" void LcdSendNibble(uint32_t nibble) { SysCtlDelay(3000); GPIOPinWrite(LCD_PORT, LCD_D4 | LCD_D5 | LCD_D6 | LCD_D7, (nibble & 0xF0)); GPIOPinWrite(LCD_PORT, LCD_RS, 0x00); GPIOPinWrite(LCD_PORT, LCD_EN, LCD_EN); SysCtlDelay(1000); GPIOPinWrite(LCD_PORT, LCD_EN, 0x00); GPIOPinWrite(LCD_PORT, LCD_D4 | LCD_D5 | LCD_D6 | LCD_D7, (nibble & 0x0F) << 4); GPIOPinWrite(LCD_PORT, LCD_RS, 0x00); GPIOPinWrite(LCD_PORT, LCD_EN, LCD_EN); SysCtlDelay(1000); GPIOPinWrite(LCD_PORT, LCD_EN, 0x00); } void LcdSendByte(uint8_t theByte) { LcdSendNibble(theByte >> 4); // Send the high nibble LcdSendNibble(theByte); // send low nibble } void LcdSendInstruction(uint8_t theInstruction) { GPIOPinWrite(LCD_PORT, LCD_RS, 0x00); // RS low for characters to display LcdSendByte(theInstruction); // Send the instruction } void lcd_gotoxy(uint8_t x, uint8_t y) { if (y == 0) LcdSendInstruction((1 << LCD_DDRAM) + LCD_ROW_1 + x); else if (y == 1) LcdSendInstruction((1 << LCD_DDRAM) + LCD_ROW_2 + x); else if (y == 2) LcdSendInstruction((1 << LCD_DDRAM) + LCD_ROW_3 + x); else if (y == 3) LcdSendInstruction((1 << LCD_DDRAM) + LCD_ROW_4 + x); } void lcd_send_character(uint8_t theChar) { GPIOPinWrite(LCD_PORT, LCD_RS, LCD_RS); // RS high for characters to display LcdSendByte(theChar); // Send the command } void lcd_print(char *p) { while (*p != 0) { lcd_send_character(*p++); } } void lcd_init(void) { SysCtlPeripheralEnable(LCD_PORT_ENABLE); GPIODirModeSet(LCD_PORT, LCD_D4, GPIO_DIR_MODE_OUT); GPIODirModeSet(LCD_PORT, LCD_D5, GPIO_DIR_MODE_OUT); GPIODirModeSet(LCD_PORT, LCD_D6, GPIO_DIR_MODE_OUT); GPIODirModeSet(LCD_PORT, LCD_D7, GPIO_DIR_MODE_OUT); GPIODirModeSet(LCD_PORT, LCD_EN, GPIO_DIR_MODE_OUT); GPIODirModeSet(LCD_PORT, LCD_RS, GPIO_DIR_MODE_OUT); GPIOPadConfigSet(LCD_PORT, LCD_D4, GPIO_STRENGTH_8MA, GPIO_PIN_TYPE_STD); GPIOPadConfigSet(LCD_PORT, LCD_D5, GPIO_STRENGTH_8MA, GPIO_PIN_TYPE_STD); GPIOPadConfigSet(LCD_PORT, LCD_D6, GPIO_STRENGTH_8MA, GPIO_PIN_TYPE_STD); GPIOPadConfigSet(LCD_PORT, LCD_D7, GPIO_STRENGTH_8MA, GPIO_PIN_TYPE_STD); GPIOPadConfigSet(LCD_PORT, LCD_EN, GPIO_STRENGTH_8MA, GPIO_PIN_TYPE_STD); GPIOPadConfigSet(LCD_PORT, LCD_RS, GPIO_STRENGTH_8MA, GPIO_PIN_TYPE_STD); SysCtlDelay(2500); LcdSendNibble(0x03); SysCtlDelay(2000); LcdSendNibble(0x03); SysCtlDelay(2000); LcdSendNibble(0x03); LcdSendNibble(0x02); LcdSendInstruction(0x28); } <\pre>
//main.c #include <stdio.h> #include "../device/lm3s_cmsis.h" #include "../driverlib/gpio.h" #include "../driverlib/sysctl.h" #include "../inc/hw_sysctl.h" int main(void) { SysTickPeriodSet(SysCtlClockGet()); SysTickEnable(); lcd_init(); lcd_gotoxy(0, 0); lcd_print("Teste"); while (1) { } }
View all questions in Keil forum