cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F4 Discovery no I/O toggle

sc2
Associate II
Posted on March 29, 2014 at 19:51

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!
6 REPLIES 6
chen
Associate II
Posted on March 31, 2014 at 11:19

Hi

''GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;''

Does

GPIO_MODE_OUTPUT_PP = 0x00

??

GPIO_InitStruct.Mode =

should be set to 0x01 for output mode.

Or it could be the HAL functions.

Posted on March 31, 2014 at 15:14

Do you need to use the form GPIO_PIN_12, not 12?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
anthony239955
Associate II
Posted on July 05, 2014 at 06:16

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.

silent
Associate II
Posted on January 23, 2015 at 14:45

i have the same problem, nothing works with HAL code, even pre-generated ''blinky'' code. I'm desperate.

re.wolff9
Senior
Posted on January 23, 2015 at 17:43

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. 

silent
Associate II
Posted on January 24, 2015 at 11:58

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