cancel
Showing results for 
Search instead for 
Did you mean: 

PG2 GPIO output on Nucleo-F767ZI doesn't function

Kristof Mulier
Associate III
Posted on May 02, 2017 at 21:49

I have made a board on which I plug the Nucleo-F767ZI microcontroller board. There is one GPIO pin that I cannot get to function as a digital output: PG2.

This is my code in mbed-os:

static

DigitalOut

myPin_A

(

PG_2

);

static

DigitalOut

myPin_B

(

PG_3

);

...

static

void

someFunction

()

{

myPin_A

.

write

(1);

// <- This one doesn't work :(

myPin_B

.

write

(1);

// <- But this one works!

}

I thought: 'Perhaps this problem has to do with mbed-os'. So I have tried the ST HAL:

static

void

someFunction

()

{

GPIO_InitTypeDef

GPIO_InitStruct

;

GPIO_InitStruct

.Pin =

GPIO_PIN_2

;

GPIO_InitStruct

.Mode =

GPIO_MODE_OUTPUT_PP

;

GPIO_InitStruct

.Pull =

GPIO_NOPULL

;

GPIO_InitStruct

.Speed =

GPIO_SPEED_FREQ_LOW

;

HAL_GPIO_Init

(

GPIOG

, &

GPIO_InitStruct

);

GPIO_InitStruct

.Pin =

GPIO_PIN_3

;

GPIO_InitStruct

.Mode =

GPIO_MODE_OUTPUT_PP

;

GPIO_InitStruct

.Pull =

GPIO_NOPULL

;

GPIO_InitStruct

.Speed =

GPIO_SPEED_FREQ_LOW

;

HAL_GPIO_Init

(

GPIOG

, &

GPIO_InitStruct

);

HAL_GPIO_WritePin

(

GPIOG

,

GPIO_PIN_2

,

GPIO_PIN_SET

);

// <- This one doesn't work :(

HAL_GPIO_WritePin

(

GPIOG

,

GPIO_PIN_3

,

GPIO_PIN_SET

);

// <- But this one works!

}

As you can see, I get exactly the same result. I've tried another Nucleo-F767ZI board standalone - I don't plug it into my custom board to reassure myself that the PG2 pin isn't affected by anything outside the Nucleo - but still got the same result.

I have posted my question also on StackOverflow:

https://electronics.stackexchange.com/questions/303038/pg2-gpio-output-on-nucleo-f767zi-doesnt-function

EDIT

I have generated a new project from scratch with CubeMX. As you know, CubeMX does not support mbed-os, but freeRTOS instead. When using freeRTOS, the pin

PG_2

works, using the code given above.

Why don't I get it working when mbed-os is running? This is so strange :(

#stm32f767zi-nucleo #stm32f767zi-nucleo-board #mbed #stm32f767
1 REPLY 1
Posted on May 02, 2017 at 23:57

Check the GPIOG registers in debugger. You can also wiggle the pin there through ODR and/or observe its state in IDR.

JW