cancel
Showing results for 
Search instead for 
Did you mean: 

8-bit LCD interfacing

M0nty
Associate II

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.

 

 

24 REPLIES 24

As you mentioned I checked with the LED blink program and that works perfectly fine. Reconfiguring the same program with the RS pin however the problem as I have mentioned occurs, it doesn't set to zero when I pass it in HAL_GPIO_WritePin (the RS pin isn't being toggled). I even reconfigured the RS pin to another pin, originally I configured it to PA0 and it didn't work, this time I just gave it to PA1 and the same problem occurs.

HAL_GPIO_WritePin(RS_GPIO_Port, RS_Pin, SET);
HAL_Delay(1000);
HAL_GPIO_WritePin(RS_GPIO_Port, RS_Pin, RESET);
HAL_Delay(1000);

 

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

 

In the datasheet it is showing that PA0 is being shared with CK_IN, could this be the problem?

No: you need to look at the board documentation - not the chip datasheet.


@M0nty wrote:

As you mentioned I checked with the LED blink program and that works perfectly fine. Reconfiguring the same program with the RS pin however the problem as I have mentioned occurs, it doesn't set to zero when I pass it in HAL_GPIO_WritePin (the RS pin isn't being toggled). I even reconfigured the RS pin to another pin, originally I configured it to PA0 and it didn't work, this time I just gave it to PA1 and the same problem occurs.

HAL_GPIO_WritePin(RS_GPIO_Port, RS_Pin, SET);
HAL_Delay(1000);
HAL_GPIO_WritePin(RS_GPIO_Port, RS_Pin, RESET);
HAL_Delay(1000);

 


So you mean this also doesn't work?

HAL_GPIO_WritePin(RS_GPIO_Port, RS_Pin, 0);
HAL_Delay(1000);
HAL_GPIO_WritePin(RS_GPIO_Port, RS_Pin, 1);
HAL_Delay(1000);
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.

Unfortunately no, this doesn't seem to work as well

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

 

As pointed by @padawan ,

RS/RW and EN pins are configured as Inputs according to your ioc file:

SofLit_0-1733225819072.png

How it did work with SET, RESET?

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.

To Monty:

to make it clear:

Inputs on the display are outputs on the cpu.

padawan

And to to your datalines too..

You have no chance to "out"put data on an "in"put pin.

So have fun with ioc. file, this should work.

(to take some chars to your Display you have to init it and don't forget

to adjust the contrast, if not you cna spend hours to find the issue. :) )   

 

Padawan