Hello everyone,I am trying to interface the LCD shield with the RA8D1 but i can't display any text in my LCD can you please help me. The pin diagram of my Keypad shield is https://www.botnroll.com/en/alphanumeric/292-lcd-shield-for-arduino.html and the picture of the LCD with the RA8D1 is also attached can you explain ow to display the text in my LCD
#include "lcd.h"
//#include "tx_api.h"
#include "hal_data.h"
#include "SEGGER_RTT/SEGGER_RTT.h"
//#include "global.h"
// LCD pin definitions (adjust according to your hardware setup)
#define LCD_RS_PIN BSP_IO_PORT_05_PIN_04
#define LCD_EN_PIN BSP_IO_PORT_10_PIN_07
#define LCD_D4_PIN BSP_IO_PORT_05_PIN_06
#define LCD_D5_PIN BSP_IO_PORT_09_PIN_07
#define LCD_D6_PIN BSP_IO_PORT_05_PIN_09
#define LCD_D7_PIN BSP_IO_PORT_04_PIN_09
void lcd_init(void);
void lcd_send_command(uint8_t command);
void lcd_set_cursor(uint8_t row, uint8_t col);
void lcd_display_string(const char *str);
void lcd_clear(void);
void lcd_send_data(uint8_t data);
void lcd_write_4bit(uint8_t value);
void lcd_pulse_enable(void);
void control_led(bool state);
void lcd_entry(void *pvParameters)
{
FSP_PARAMETER_NOT_USED (pvParameters);
SEGGER_RTT_printf(0, "Starting LCD initialization...\n");
lcd_init();
SEGGER_RTT_printf(0, "LCD initialization complete.\n");
// lcd_display_string("Essl Security");
// lcd_set_cursor(1, 0);
// lcd_display_string("4 Door Controller");
lcd_display_string("Mathan");
while (1)
// SEGGER_RTT_printf(0, "Setting cursor and displaying string...\n");
// lcd_set_cursor(0, 0);
control_led(true);
// SEGGER_RTT_printf(0, "LED ON\n");
// tx_thread_sleep(500);
// SEGGER_RTT_printf(0, "Clearing display...\n");
// lcd_clear();
// control_led(false); // Turn off LED
// SEGGER_RTT_printf(0, "LED OFF\n");
// tx_thread_sleep(500); // Increased delay for visibility
vTaskDelay(5);
}
void control_led(bool state)
R_IOPORT_PinWrite(&g_ioport_ctrl, BSP_IO_PORT_04_PIN_13, state ? BSP_IO_LEVEL_HIGH : BSP_IO_LEVEL_LOW);
void lcd_init(void)
// Set GPIO pins as output
R_IOPORT_PinCfg(&g_ioport_ctrl, LCD_RS_PIN, IOPORT_CFG_PORT_DIRECTION_OUTPUT);
R_IOPORT_PinCfg(&g_ioport_ctrl, LCD_EN_PIN, IOPORT_CFG_PORT_DIRECTION_OUTPUT);
R_IOPORT_PinCfg(&g_ioport_ctrl, LCD_D4_PIN, IOPORT_CFG_PORT_DIRECTION_OUTPUT);
R_IOPORT_PinCfg(&g_ioport_ctrl, LCD_D5_PIN, IOPORT_CFG_PORT_DIRECTION_OUTPUT);
R_IOPORT_PinCfg(&g_ioport_ctrl, LCD_D6_PIN, IOPORT_CFG_PORT_DIRECTION_OUTPUT);
R_IOPORT_PinCfg(&g_ioport_ctrl, LCD_D7_PIN, IOPORT_CFG_PORT_DIRECTION_OUTPUT);
R_IOPORT_PinCfg(&g_ioport_ctrl, BSP_IO_PORT_04_PIN_13, IOPORT_CFG_PORT_DIRECTION_OUTPUT);
// Wait for LCD to power up
vTaskDelay(1);
// Initialize LCD in 4-bit mode
lcd_write_4bit(0x03);
lcd_write_4bit(0x02);
vTaskDelay(1); // Added delay
lcd_send_command(0x28); // Function set: 4-bit mode, 2 lines, 5x8 font
vTaskDelay(2); // Added delay
lcd_send_command(0x0C); // Display control: Display on, cursor off, blink off
lcd_send_command(0x06); // Entry mode set: Increment cursor, no display shift
lcd_clear(); // Clear display
void lcd_write_4bit(uint8_t value)
R_IOPORT_PinWrite(&g_ioport_ctrl, LCD_D4_PIN, (value & 0x01) ? BSP_IO_LEVEL_HIGH : BSP_IO_LEVEL_LOW);
R_IOPORT_PinWrite(&g_ioport_ctrl, LCD_D5_PIN, (value & 0x02) ? BSP_IO_LEVEL_HIGH : BSP_IO_LEVEL_LOW);
R_IOPORT_PinWrite(&g_ioport_ctrl, LCD_D6_PIN, (value & 0x04) ? BSP_IO_LEVEL_HIGH : BSP_IO_LEVEL_LOW);
R_IOPORT_PinWrite(&g_ioport_ctrl, LCD_D7_PIN, (value & 0x08) ? BSP_IO_LEVEL_HIGH : BSP_IO_LEVEL_LOW);
lcd_pulse_enable();
void lcd_pulse_enable(void)
R_IOPORT_PinWrite(&g_ioport_ctrl, LCD_EN_PIN, BSP_IO_LEVEL_LOW);
R_IOPORT_PinWrite(&g_ioport_ctrl, LCD_EN_PIN, BSP_IO_LEVEL_HIGH);
void lcd_send_command(uint8_t command)
R_IOPORT_PinWrite(&g_ioport_ctrl, LCD_RS_PIN, BSP_IO_LEVEL_LOW);
lcd_write_4bit(command >> 4);
lcd_write_4bit(command & 0x0F);
vTaskDelay(2);
void lcd_send_data(uint8_t data)
R_IOPORT_PinWrite(&g_ioport_ctrl, LCD_RS_PIN, BSP_IO_LEVEL_HIGH);
lcd_write_4bit(data >> 4);
lcd_write_4bit(data & 0x0F);
void lcd_set_cursor(uint8_t row, uint8_t col)
uint8_t command = row == 0 ? 0x80 + col : 0xC0 + col;
lcd_send_command(command);
void lcd_clear(void)
lcd_send_command(0x01);
void lcd_display_string(const char *str)
while (*str)
lcd_send_data(*str++);
Hi Mukesh,
Can you please show me the Pin settings on FSP? To see if you have set the IO as right function.
From our aspect, we can only help you to check if you have set all the pins correctly but cannot check the LCD communication protocol is all right.
BR,
NP_Renesas
I have given configured these as the output pin can you check that
drive.google.com/.../view
I see your question is about LCD on RA8D1, but in your project, the pin config is based on RA6M3:
Can you please change it to RA8D1? And I see you are using RTOS for this project, can you please try to drive the LCD on a barely project first?
So my suggestion is to start from creating a new project with no RTOS and try to drive the LCD.