2023-03-24 05:18 PM
NUCLEO-L4R5ZI board, CN12 header: Pin76 = PG7, pin66 = PG8.
SB130 and SB131 have been removed from the board.
config PG7, PG8 as GPIO output pins, but cannot toggle these two pins
Here is the code:
GPIO_InitTypeDef GPIO_InitStructure = {0};
__HAL_RCC_GPIOG_CLK_ENABLE();
GPIO_InitStructure.Pin = GPIO_PIN_1 | GPIO_PIN_7 | GPIO_PIN_8;
GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStructure.Pull = GPIO_NOPULL;
GPIO_InitStructure.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
HAL_GPIO_Init(GPIOG, &GPIO_InitStructure);
HAL_GPIO_WritePin(GPIOG, GPIO_PIN_1, GPIO_PIN_RESET); // set to LOW, OK
HAL_GPIO_WritePin(GPIOG, GPIO_PIN_1, GPIO_PIN_SET); // set to HIGH, OK. PG1 toggles OK.
HAL_GPIO_WritePin(GPIOG, GPIO_PIN_7, GPIO_PIN_RESET); // LOW. PG7 always low
HAL_GPIO_WritePin(GPIOG, GPIO_PIN_7, GPIO_PIN_SET); // set to HIGH, PG7 always low (measured), cannot set to high!
HAL_GPIO_WritePin(GPIOG, GPIO_PIN_8, GPIO_PIN_RESET); // LOW. PG8 always low
HAL_GPIO_WritePin(GPIOG, GPIO_PIN_8, GPIO_PIN_SET); // set to HIGH, PG8 always low (measured), cannot set to high!
Note: (1) PG0, and PG1 pins can set/toggle correctly.
(2) PG7 and PG8 cannot set/toggle correctly.
Thanks.
Solved! Go to Solution.
2023-03-26 02:36 AM
PG2 to PG15 pins are supplied not from VDD but from VDDIO2, and you have to switch the VDDIO2 domain on by setting PWR_CR2.IOSV
JW
2023-03-25 10:09 AM
Hello.
Are jumpers SB193 and SB 195 closed ?
2023-03-25 10:52 AM
Yes. SB193 and 195 are closed.
2023-03-26 12:54 AM
OK.some ideas:
Have you connect something to CN12 pins 67 / 66, if yes, disconnect and test again.
Maybe check the connection from these CN12 pins to MCU pins or to SB130/131 to make sure youre measuring right pins/board is ok/you have located jumpers correctly.
Check also that pins are not grounded.
In code, there is no other initializations, for example LPUART1 which overrides the pin ?
2023-03-26 02:36 AM
PG2 to PG15 pins are supplied not from VDD but from VDDIO2, and you have to switch the VDDIO2 domain on by setting PWR_CR2.IOSV
JW
2023-03-26 12:05 PM
Thanks for help. This issue is solved by calling "HAL_PWREx_EnableVddIO2();"
as JW pointed out "PG2 to PG15 pins are supplied not from VDD but from VDDIO2, and you have to switch the VDDIO2 domain on by setting PWR_CR2.IOSV"
Thank you.