cancel
Showing results for 
Search instead for 
Did you mean: 

8-bit LCD interfacing

M0nty
Visitor

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.

 

 

5 REPLIES 5

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?

Ghofrane GSOURI
ST Employee

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


@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;

 

SofLit
ST Employee

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.

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