8-bit LCD interfacing
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-11-29 4: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.
Solved! Go to Solution.
- Labels:
-
STM32CubeIDE
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-11-29 4:48 AM - edited ‎2024-11-29 4:49 AM
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:
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 designed from scratch never works and cannot be patched up to make it work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-11-29 4:55 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-11-29 5:03 AM
@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 designed from scratch never works and cannot be patched up to make it work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-11-29 5:10 AM
Hello @M0nty and welcome to the community,
Could you please share your ioc file as well as sharing your code?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-11-29 5:13 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-11-29 8:22 PM
I have also tried the same thing by substituting rs as GPIO_PIN_RESET but the same issue occurs
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-11-29 8:24 PM - edited ‎2024-11-29 8:55 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-11-29 8:49 PM - edited ‎2024-11-29 10:04 PM
I am actually passing rs as an argument from a function call as shown so I'm not sure if this also causes a problem. (Edit: I tried changing the type of argument for rs from int to GPIO_PinState: void send_cmd(char data, GPIO_PinState rs) but this also doesn't work and the same problem occurs.
send_cmd(0x38,0);
void send_cmd (char data, int rs)
{
HAL_GPIO_WritePin(RS_GPIO_Port, RS_Pin, rs);
}
.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-11-30 1:42 AM
Time to go back to basics.
Disconnect the LCD.
Go back to a basic "blinky" program which just toggles the LED on the Nucleo board - just a loop with inline delays.
Once that is working, change it to toggle your RS pin.
Does the pin toggle?
A complex system designed from scratch never works and cannot be patched up to make it work.
