2014-03-29 11:51 AM
I am trying to toggle an I/O line to measure timing for benchmarking dsp algorithms on an STM32F407VGT. I generated the HAL using STM32CubeMX and set PD12 and PC8 to outputs and configured them as output push-pull with no pull-up. The generated code includes the following which is called prior to entering the infinite while in main().
/*Configure GPIO pin : PD12 */GPIO_InitStruct.Pin = GPIO_PIN_12;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_MEDIUM;
HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);Later I use the following to set and reset the I/O pin: // Set PD12 at the beginning of the calculation
HAL_GPIO_WritePin(GPIOD, 12, GPIO_PIN_SET);
// Clear PD12 at the end of the calculation
HAL_GPIO_WritePin(GPIOD, 12, GPIO_PIN_RESET);Yet, the I/O pin is not toggling. I believe I configured the clock tree correctly and I'll include a screen grab from STM32CubeMX. Am I missing anything obvious? Thanks!
2014-03-31 02:19 AM
Hi
''GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;'' DoesGPIO_MODE_OUTPUT_PP = 0x00 ??GPIO_InitStruct.Mode = should be set to 0x01 for output mode. Or it could be the HAL functions.2014-03-31 06:14 AM
Do you need to use the form GPIO_PIN_12, not 12?
2014-07-04 09:16 PM
Dunno if this is the solution for you, but one of the first things I forgot when running into this same problem is to start the proper gpio clock. In your case, you need to make sure you call __GPIOD_CLK_ENABLE() first.
2015-01-23 05:45 AM
i have the same problem, nothing works with HAL code, even pre-generated ''blinky'' code. I'm desperate.
2015-01-23 08:43 AM
The functions work with bitmasks. So GPIO_PIN_12 is defined to be (1<<12) or 0x1000 or 4096. Calling the function with ''12'' as the argument will set or clear pins two and three. (1<<2) + (1<<3) = 4+8 = 12.
2015-01-24 02:58 AM
void Delay(__IO uint32_t nCount) {
while(nCount--) { } } while (1) { // Add your code here. HAL_GPIO_WritePin(GPIOA, GPIO_PIN_1, GPIO_PIN_SET); Delay(200000L); HAL_GPIO_WritePin(GPIOA, GPIO_PIN_1, GPIO_PIN_RESET); Delay(200000L); } it's my code, the pin allways stuck on 1 state, if i change code to first reset then set pin - it will stuck on 0 state