2024-11-29 04:38 AM
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.
2024-11-30 03:51 AM
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);
2024-11-30 06:36 AM
So, again, have you checked the Nucleo board's User Manual and/or schematics to see that nothing else is using that pin?
2024-12-01 10:11 PM
2024-12-02 01:42 AM
No: you need to look at the board documentation - not the chip datasheet.
2024-12-02 01:45 AM
@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);
2024-12-02 08:45 PM
Unfortunately no, this doesn't seem to work as well
2024-12-02 11:44 PM
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
2024-12-03 03:37 AM
As pointed by @padawan ,
RS/RW and EN pins are configured as Inputs according to your ioc file:
How it did work with SET, RESET?
2024-12-03 05:12 AM
To Monty:
to make it clear:
Inputs on the display are outputs on the cpu.
padawan
2024-12-03 07:43 AM - edited 2024-12-03 07:44 AM