2024-06-05 8:35 AM
Hello everyone,
I am new to STM32 architecture and configuration. I am trying to configure new GPIO ports and pins in an STM32H745i-DISCO board. I had some previous code for the pin configuration, but I could not 100% map it to the user manual for the board. The code is the following. I could not match these definitions to any from the manual. Could anyone help me with the mapping for pins D0-D15 on the board? Thank you very much
#define LD6_Port GPIOD
#define LD7_Port GPIOI
#define LD8_Port GPIOB
#define LD9_Port GPIOC
#define LD10_Port GPIOA
#define B1_Port GPIOC
#define LD6_Pin GPIO_PIN_3
#define LD7_Pin GPIO_PIN_2
#define LD8_Pin GPIO_PIN_15
Solved! Go to Solution.
2024-06-06 5:57 AM
Just with the HAL_GPIO_WritePin function you mean? D10 is working perfectly (new pin). D14 and 15 not at all
2024-06-06 6:24 AM
Please show your code with HAL implementation by toggling GPIOD pin 12 and 13. They correspond respectively to CN2/D15 and D14.
2024-06-06 6:38 AM
typedef unsigned int uint;
typedef unsigned int uint32;
typedef uint16_t uint16;
typedef uint8_t uint8;
typedef uint8_t byte;
#define LD6_Port GPIOD
#define LD7_Port GPIOI
#define LD8_Port GPIOB
#define LD9_Port GPIOD
#define LD10_Port GPIOD
#define B1_Port GPIOC
#define LD6_Pin GPIO_PIN_3
#define LD7_Pin GPIO_PIN_2
#define LD8_Pin GPIO_PIN_15
#define LD9_Pin GPIO_PIN_13
#define LD10_Pin GPIO_PIN_12
#define B1_Pin GPIO_PIN_13
typedef struct GPIO_Pin {
GPIO_TypeDef* port;
uint16_t pin;
GPIO_PinState initialState;
uint32_t state;
} GPIO_Pin;
GPIO_Pin outputs[] = {
{.port = LD6_Port, .pin = LD6_Pin, .initialState = GPIO_PIN_SET, .state = 0},
{.port = LD7_Port, .pin = LD7_Pin, .initialState = GPIO_PIN_SET, .state = 0},
{.port = LD8_Port, .pin = LD8_Pin, .initialState = GPIO_PIN_RESET, .state = 0},
{.port = LD9_Port, .pin = LD9_Pin, .initialState = GPIO_PIN_RESET, .state = 0},
{.port = LD10_Port, .pin = LD10_Pin, .initialState = GPIO_PIN_RESET, .state = 0},
};
const uint8_t outputCount = sizeof(outputs) / sizeof(GPIO_Pin);
void initOutputs() {
// Common settings
GPIO_InitTypeDef gpioInit = { 0 };
gpioInit.Mode = GPIO_MODE_OUTPUT_PP;
gpioInit.Pull = GPIO_NOPULL;
gpioInit.Speed = GPIO_SPEED_FREQ_LOW;
for (uint16 i = 0; i < outputCount; i++) {
HAL_GPIO_WritePin(outputs[i].port, outputs[i].pin, outputs[i].initialState);
gpioInit.Pin = outputs[i].pin;
HAL_GPIO_Init(outputs[i].port, &gpioInit);
}
}
void toggleLed(GPIO_Led led) {
HAL_GPIO_TogglePin(outputs[led].port, outputs[led].pin);
}
void setLed(GPIO_Led led, GPIO_State state) {
HAL_GPIO_WritePin(outputs[led].port, outputs[led].pin, state == LOW ? GPIO_PIN_RESET : GPIO_PIN_SET);
if (state != outputs[led].initialState) {
outputs[led].state = 50;
}
}
2024-06-06 6:47 AM - edited 2024-06-06 6:56 AM
No.
I requested a test like this in a while loop in main.c:
while(1)
{
HAL_GPIO_TogglePin(GPIOD, GPIO_PIN_12);
HAL_GPIO_TogglePin(GPIOD, GPIO_PIN_13);
HAL_Delay(500);
}
Are you seeing GPIOD pin12/pin13 are toggling?
2024-06-12 3:40 AM
FYI,
This is just to confirm my suspicion in my previous comment regarding the discrepancy in the Arduino D0/D1 CN6 connector in table 8: PB6 and PB7 will be respectively replaced by PB10 and PB11. Also USART1 will be replaced by USART3.
The internal Ticket 183533 has been opened to fix the issue.
2025-05-06 2:22 AM
@mƎALLEm wrote:
FYI,
This is just to confirm my suspicion in my previous comment regarding the discrepancy in the Arduino D0/D1 CN6 connector in table 8: PB6 and PB7 will be respectively replaced by PB10 and PB11. Also USART1 will be replaced by USART3.
The internal Ticket 183533 has been opened to fix the issue.
Document fixed. It was published on the ST website.