Skip to main content
M0nty
Associate
November 29, 2024
Solved

8-bit LCD interfacing

  • November 29, 2024
  • 3 replies
  • 7417 views

Hi everyone I'm rather new with programming with STM32 controllers and I am currently using NUCLEO-L432KC. Currently I'm facing a problem with HAL_GPIO_WritePin() function. I am interfacing with a 16x2 LCD and I am trying to write to the RS pin via the function I have mentioned, however I am facing a problem where the RS isn't being set to the desired value I am providing. I have provided the value like so: HAL_GPIO_WritePin(RS_GPIO_Port, RS_Pin, rs);

Where I have given rs = 0 but the function is setting the value as 1. I have also provided the photo of the RS pin configuration from the IOC file.

 

 

Best answer by padawan

Hi

from your ioc file 

PA0.GPIOParameters=GPIO_Label
PA0.GPIO_Label=RS
PA0.Locked=true
PA0.Signal=GPIO_Input

You see the Error? "GPIO_Input"? 

padawan_0-1733211820707.png

padawan

 

3 replies

Andrew Neil
Super User
November 29, 2024

Welcome to the forum!

 


@M0nty wrote:

Hi everyone I'm rather new with programming with STM32 controllers


Do you have experience with any other microcontroller(s)? With programming in general ?

Please post your source code - instructions here:

https://community.st.com/t5/community-guidelines/how-to-write-your-question-to-maximize-your-chances-to-find-a/ta-p/575228

 

Also your schematic of how the LCD is connected.

A good, clear photo may also help.

Have you checked the Nucleo board's User Manual and/or schematics to see that nothing else is using that pin?

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
Ghofrane GSOURI
Technical Moderator
November 29, 2024

Hello @M0nty 

First let me thank you for posting.

By checking the  HAL_GPIO_WritePin () the parameter :

 

PinState: specifies the value to be written to the selected bit.

* This parameter can be one of the GPIO_PinState enum values:

* @arg GPIO_PIN_RESET: to clear the port pin

* @arg GPIO_PIN_SET: to set the port pin

Ensure that you are passing the correct value for rs. The PinState parameter should be either

GPIO_PIN_SET or GPIO_PIN_RESET, not just 0 or 1. If you are using a variable like rs, make sure

it is defined as:

GPIO_PinState rs = GPIO_PIN_RESET; // or GPIO_PIN_SET

Instead of:

int rs = 0; // This may cause issues

THX

Ghofrane

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
Andrew Neil
Super User
November 29, 2024

@Ghofrane GSOURI wrote:

The PinState parameter should be either GPIO_PIN_SET or GPIO_PIN_RESET, not just 0 or 1.e


The GPIO_PIN_SET and GPIO_PIN_RESET values are 1 and 0 - so it should be OK ...

 

/** 
 * @brief GPIO Bit SET and Bit RESET enumeration 
 */
typedef enum
{
 GPIO_PIN_RESET = 0U,
 GPIO_PIN_SET
}GPIO_PinState;

 

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
Ghofrane GSOURI
Technical Moderator
November 29, 2024

Hello @Andrew Neil 

Let 's just try to use the parameter value as it is GPIO_PIN_SET or GPIO_PIN_RESET and see what's happen.

THX

Ghofrane

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
mƎALLEm
Technical Moderator
November 29, 2024

Hello @M0nty and welcome to the community,

Could you please share your ioc file as well as sharing your code?

"To give better visibility on the answered topics, please click on ""Accept as Solution"" on the reply which solved your issue or answered your question."
M0nty
M0ntyAuthor
Associate
November 30, 2024

No problem, I have provided my ioc file as requested to help you get a better understanding of my configuration