2024-10-16 01:27 AM - last edited on 2024-10-16 02:44 AM by Mohammad MORADI ESFAHANIASL
Hi everyone,
I'm working with the STM32F429i-Disc1 board, writing code from scratch, and I encountered something odd. I created an empty project for the LCD, and during the LTDC pin initialization, I mistakenly set the alternate function (AF) to the wrong value.
According to the STM32F429-Disc1 schematic, the R3, R6, G3 & B4 pins of the LCD are connected to PB0, PB1, PG10, and PG12, respectively. As per the STM32F429xx datasheet, the alternate function to configure these pins as LCD_R3, LCD_R6, LCD_G3, and LCD_B4 should be AF9. However, by mistake, I set the alternate function to AF14, which is meant for other peripherals.
The strange thing is, the code still works! :\ I'm trying to figure out why. Shouldn't this wrong AF setting prevent the LCD from working properly?
Does this mean that the effect of setting these pins (PB0, PB1, PG10, and PG12) to AF14 is null, or is something else happening behind the scenes?
Any insights or explanations would be really helpful!
Thanks in advance.
2024-10-16 03:12 AM - edited 2024-10-16 06:29 AM
hello @Shreayas_Acharaya
I'm checking this internally (throw the internal ticket number 193915) and I will be back to you as soon as I have more information.
Best Regards.
STTwo-32
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.
2024-10-17 12:30 AM - edited 2024-10-17 12:32 AM
Setting AF to unassigned value means that the result is undefined, i.e. it may do anything, including a lucky coincidence of being assigned to LTDC as consequence of logic optimization.
You should not rely on it, but you should also not be stressed out by that.
(There is also the possibility that enabling LTDC simply overrides the AF setting in a way ST refuses to document. There is precedent for that, too; e.g. enabling OTG USB overrides the related DP/DM pins AF settings.)
JW
2024-10-17 01:39 AM
Hi @waclawek.jan,
Thanks for the explanation!
I actually tried de-initializing these pins (PB0, PB1, PG10, and PG12) completely, but the LCD still works. It's strange, as I would expect the display to stop functioning if the pins weren't properly configured.
Additionally, I experimented by randomly de-initializing some other pins, and I noticed that the color effects on the LCD change depending on which pins are uninitialized.
Does this mean that if certain data lines are de-initialized, the color output on the LCD will be incorrect, but the display will still function partially because the remaining data lines are still active?
Any thoughts on this?
2024-10-17 06:21 AM
I don't know what do you mean by "de-initializing" in terms of GPIO registers content.
If you change AF (respective field in GPIOx_AFR[]) to a value which is allocated (e.g. set it to 1 for TIM1_CH2N on PB0), it will be connected to that peripheral (in this particular case, if you don't have TIM1_CH2N enabled on some other pin, it is threestated/floating).
JW
2024-11-21 08:06 AM
Hello @Shreayas_Acharaya
After checking, when we change to the wrong alternate functions, the PB0, PB1, PG10, and PG12 pins turn low. This has an impact on LCD pins. By probing the LTDC pins (LCD_R3, LCD_R6), we observe that they are always low with the incorrect alternate function. The user will notice a difference in color intensity. For example, if LCD_R3 is mapped to PB0, which is in the least significant bit (LSB) part, setting it to 0 by choosing the wrong alternate function changes the red color value from FF to F7. The user should map the alternate functions as described in the datasheet.
Best Regards.
STTwo-32
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.