2019-05-23 06:04 AM
2019-05-24 04:34 AM
Be sure to understand what is going on here.
You are using a LCD display that typically contains INPUT only port pins. The STM32 CPU or any other must be configured for OUTPUT only GPIO direction for the port pins. Typically called push-pull meaning that if you output a "1" (HIGH), the port pin will be raised to +3v3 (since STM32 is a 3v3 CPU on the port pins.
If you output a "0" (LOW), the voltage on the port pin is often close to 0 volts.
Guessing that the initialization was only for D4..D7 pins due to the original code by the author configured the LCD display to use 4 bit mode so D0..D3 were not used at all in the original reference design.
Since this project is for use with 8 bit mode, the init code is required to expand to use the full 8 bits of Port D on the CPU.
2019-05-23 06:57 AM
@PKuma.12 , only some general comments:
1) check your wiring between the discovery and LCD board
2) check your power supply details
3) Review this page on the use of the 4 bit mode for the LCD display:
https://www.thehardwareguy.co.uk/blog/stm32f4-lcd-display
5) Break down the code to only initialization, clear the display, print a few chars and stop. Does that work? If not, check your timing as well for the GPIO routines. Perhaps the CPU is sending out the highs and lows too fast?
2019-05-23 10:04 PM
@Mon2
I reviewed the page you mention above I have some doubts that the register R1 R2 and capacitor C1 you added is it necessary to add these.
should I replaced R1 by 10K potentiometer.
I am not able to download code from link on page.
2019-05-23 10:24 PM
@Mon2 (Community Member)
Thank you for the answer
I reviewed the page you mention above I have some doubts that the register R1 R2 and capacitor C1 you added is it necessary to add these.
should I replaced R1 by 10K potentiometer.
I am not able to download code from link on page.
2019-05-24 03:20 AM
I tried all my possible ways it is not working. please help me to sort it out.
2019-05-24 04:02 AM
The use of a 10k potentiometer is nice to have to allow for adjusting the LCD display's contrast for easier viewing. You can also find many articles on this subject on the internet including Adafruit:
https://learn.adafruit.com/character-lcds/wiring-a-character-lcd
Can you post your wiring diagram to the LCD display and the STM32 kit?
Which STM32F4 discovery kit are you using?
Which display are you using exactly?
What is the controller chip on the backside of the display?
2019-05-24 04:28 AM
Inside your code, you are using the LCD display in 8 bit mode. Ok.
The STM32 CPU, Port D is being used to interface with the LCD display. Ok.
But in a quick review of your port initialization code, do not see any references to properly configure Port D0 pins D0..D3 - can you confirm this?
/**
* @brief GPIO Initialization Function
* @param None
* @retval None
*/
static void MX_GPIO_Init(void)
{
GPIO_InitTypeDef GPIO_InitStruct = {0};
/* GPIO Ports Clock Enable */
__HAL_RCC_GPIOB_CLK_ENABLE();
__HAL_RCC_GPIOD_CLK_ENABLE();
__HAL_RCC_GPIOE_CLK_ENABLE();
/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(GPIOB, D0_Pin|D1_Pin|D2_Pin|D3_Pin, GPIO_PIN_RESET);
/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(GPIOD, D4_Pin|D5_Pin|D6_Pin|D7_Pin, GPIO_PIN_RESET);
/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(GPIOE, RS_Pin|E_Pin, GPIO_PIN_RESET);
/*Configure GPIO pins : D0_Pin D1_Pin D2_Pin D3_Pin */
GPIO_InitStruct.Pin = D0_Pin|D1_Pin|D2_Pin|D3_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
/*Configure GPIO pins : D4_Pin D5_Pin D6_Pin D7_Pin */
GPIO_InitStruct.Pin = D4_Pin|D5_Pin|D6_Pin|D7_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
/*Configure GPIO pins : RS_Pin E_Pin */
GPIO_InitStruct.Pin = RS_Pin|E_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
}
Specifically, Line 32 above is only configuring port pins D4..D7 of Port D to be push-pull style.
Try with:
GPIO_InitStruct.Pin = D0_Pin|D1_Pin|D2_Pin|D3_Pin|D4_Pin|D5_Pin|D6_Pin|D7_Pin;
and post your results.
2019-05-24 04:30 AM
Also revise line 19:
/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(GPIOD, D4_Pin|D5_Pin|D6_Pin|D7_Pin, GPIO_PIN_RESET);
to read as:
/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(GPIOD, D0_Pin|D1_Pin|D2_Pin|D3_Pin|D4_Pin|D5_Pin|D6_Pin|D7_Pin, GPIO_PIN_RESET);
2019-05-24 04:34 AM
Be sure to understand what is going on here.
You are using a LCD display that typically contains INPUT only port pins. The STM32 CPU or any other must be configured for OUTPUT only GPIO direction for the port pins. Typically called push-pull meaning that if you output a "1" (HIGH), the port pin will be raised to +3v3 (since STM32 is a 3v3 CPU on the port pins.
If you output a "0" (LOW), the voltage on the port pin is often close to 0 volts.
Guessing that the initialization was only for D4..D7 pins due to the original code by the author configured the LCD display to use 4 bit mode so D0..D3 were not used at all in the original reference design.
Since this project is for use with 8 bit mode, the init code is required to expand to use the full 8 bits of Port D on the CPU.
2019-05-27 02:48 AM
I am using STM32407VG Discovery kit and Hitachi HD44780 16x2 LCD display.