‎2019-04-19 09:33 PM
I have a simple switch on an LED project on a homemade STM32F405 development board. I am using STM32 Cube-MX and It is all working OK and turns an LED on and off via a momentary switch on subsequent button presses. The problem is that on starting the program the externally connected LED starts off in the on state whereas I would like it to start in the off state. Here is the relevant section of my main.c code and I was wondering how I can change it to make this happen please? I am hoping that this code snippet is where it can be changed but I can post the whole main.c if required.
while (1)
{
// https://www.youtube.com/watch?v=sWe4kvzLMjY
if(HAL_GPIO_ReadPin(GPIOC, GPIO_PIN_3) && tempVar)
{
// wait 5 ms
HAL_Delay(5);
HAL_GPIO_TogglePin(GPIOA, GPIO_PIN_5);
tempVar = false;
}
else if(HAL_GPIO_ReadPin(GPIOC, GPIO_PIN_3)==GPIO_PIN_RESET)
{
// wait 5 ms
HAL_Delay(5);
tempVar = true;
}
Solved! Go to Solution.
‎2019-04-20 12:14 AM
It's not there, it's when the GPIO is configured as output that you shall set its output level prior.
‎2019-04-20 12:14 AM
It's not there, it's when the GPIO is configured as output that you shall set its output level prior.
‎2019-04-20 12:48 AM
Thanks for the reply but exactly where please? In the configuration UI of STM32 Cube-MX is it.
I am only learning this so I really need specific information please 😀
‎2019-04-20 01:51 AM
Update - this post and the micro 😀 I found the config setting here https://imgur.com/a/gnV21Z9 thanks KIC8462852 EPIC204278916
Working as I wanted. Cheers and Happy Easter.