Skip to main content
Associate II
December 18, 2023
Solved

the built in led of stm32l4r9 discovery kit works plus led attached to other gpios don't work

i'm using stm32l4r9 discovery kit and the built in led of stm32l4r9 discovery kit works but led attached to other gpios don't work. no mater if i set or rest it.

This topic has been closed for replies.
kanuz_khanBest answer
Associate II
December 19, 2023

kanuz_khan_0-1702967972350.png

On the documentation it states d13 as PB13?
the positive leg of the led is attached to 3.3v and the negative to d13 i just added a resistor equal to r5 on between ground and negative le and its working now 

17 replies

ST Employee
December 18, 2023

Hello @kanuz_khan, welcome to ST Community, 

That's probably a wiring issue! Also, check if the GPIO you're using as configured correctly as output pins 

 

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
Associate II
December 18, 2023

i've checked the wiring it works fine when i attach it to vcc

mƎALLEm
ST Technical Moderator
December 18, 2023

Hello @kanuz_khan 

Could you please specify which LEDs attached to other GPIOs you are talking about? LEDs you connected externally or what? which GPIOs? How did you connect the LEDs? 

Please provide more details and if possible your schematics.

Thank you.

To give better visibility on the answered topics, please click "Best answer" on the reply which solved your issue or answered your question.
Associate II
December 18, 2023

 i'm using ph4 and gpio_8

Associate II
December 18, 2023

#include "main.h"

void SystemClock_Config(void);

static void MX_GPIO_Init(void);

int main(void)

{

HAL_Init();

SystemClock_Config();

MX_GPIO_Init();

HAL_GPIO_WritePin(GPIOD, GPIO_PIN_8, GPIO_PIN_SET);

while (1)

{

HAL_GPIO_TogglePin(GPIOH, GPIO_PIN_4);

HAL_Delay(1000);

HAL_GPIO_WritePin(GPIOD, GPIO_PIN_8, GPIO_PIN_SET);

}

}

void SystemClock_Config(void)

{

RCC_OscInitTypeDef RCC_OscInitStruct = {0};

RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};

 

/** Configure the main internal regulator output voltage

*/

if (HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE1_BOOST) != HAL_OK)

{

Error_Handler();

}

/** Initializes the RCC Oscillators according to the specified parameters

* in the RCC_OscInitTypeDef structure.

*/

RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_MSI;

RCC_OscInitStruct.MSIState = RCC_MSI_ON;

RCC_OscInitStruct.MSICalibrationValue = 0;

RCC_OscInitStruct.MSIClockRange = RCC_MSIRANGE_6;

RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;

RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_MSI;

RCC_OscInitStruct.PLL.PLLM = 1;

RCC_OscInitStruct.PLL.PLLN = 60;

RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;

RCC_OscInitStruct.PLL.PLLQ = RCC_PLLQ_DIV2;

RCC_OscInitStruct.PLL.PLLR = RCC_PLLR_DIV2;

if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)

{

Error_Handler();

}

/** Initializes the CPU, AHB and APB buses clocks

*/

RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK

|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;

RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;

RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;

RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;

RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;

if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5) != HAL_OK)

{

Error_Handler();

}

}

Associate II
December 18, 2023

 

static void MX_GPIO_Init(void)

{

GPIO_InitTypeDef GPIO_InitStruct = {0};

/* USER CODE BEGIN MX_GPIO_Init_1 */

/* USER CODE END MX_GPIO_Init_1 */

 

/* GPIO Ports Clock Enable */

__HAL_RCC_GPIOI_CLK_ENABLE();

__HAL_RCC_GPIOH_CLK_ENABLE();

__HAL_RCC_GPIOE_CLK_ENABLE();

__HAL_RCC_GPIOB_CLK_ENABLE();

__HAL_RCC_GPIOA_CLK_ENABLE();

__HAL_RCC_GPIOG_CLK_ENABLE();

HAL_PWREx_EnableVddIO2();

__HAL_RCC_GPIOD_CLK_ENABLE();

__HAL_RCC_GPIOC_CLK_ENABLE();

__HAL_RCC_GPIOF_CLK_ENABLE();

 

/*Configure GPIO pin Output Level */

HAL_GPIO_WritePin(GPIOH, MIC_VDD_Pin|DSI_SPI_USART_CS_Pin|greenled_Pin, GPIO_PIN_RESET);

 

/*Configure GPIO pin Output Level */

HAL_GPIO_WritePin(JOY_SEL_GPIO_Port, JOY_SEL_Pin, GPIO_PIN_RESET);

 

/*Configure GPIO pin Output Level */

HAL_GPIO_WritePin(external_led_GPIO_Port, external_led_Pin, GPIO_PIN_RESET);

 

/*Configure GPIO pin Output Level */

HAL_GPIO_WritePin(SPI2_CS_GPIO_Port, SPI2_CS_Pin, GPIO_PIN_RESET);

 

/*Configure GPIO pin Output Level */

HAL_GPIO_WritePin(MFX_WAKEUP_GPIO_Port, MFX_WAKEUP_Pin, GPIO_PIN_RESET);

 

/*Configure GPIO pins : OCTOSPIM_P2_IO1_Pin OCTOSPIM_P2_IO2_Pin OCTOSPIM_P2_CLK_Pin OCTOSPIM_P2_IO0_Pin */

GPIO_InitStruct.Pin = OCTOSPIM_P2_IO1_Pin|OCTOSPIM_P2_IO2_Pin|OCTOSPIM_P2_CLK_Pin|OCTOSPIM_P2_IO0_Pin;

GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;

GPIO_InitStruct.Pull = GPIO_NOPULL;

GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;

GPIO_InitStruct.Alternate = GPIO_AF5_OCTOSPIM_P2;

HAL_GPIO_Init(GPIOI, &GPIO_InitStruct);

 

/*Configure GPIO pins : MIC_VDD_Pin DSI_SPI_USART_CS_Pin greenled_Pin */

GPIO_InitStruct.Pin = MIC_VDD_Pin|DSI_SPI_USART_CS_Pin|greenled_Pin;

GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;

GPIO_InitStruct.Pull = GPIO_NOPULL;

GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;

HAL_GPIO_Init(GPIOH, &GPIO_InitStruct);

 

/*Configure GPIO pins : PSRAM_NBL0_Pin PSRAM_NBL1_Pin PSRAM_A20_Pin PSRAM_A19_Pin

D7_Pin D6_Pin D12_Pin D5_Pin

D11_Pin D4_Pin D10_Pin D9_Pin

D8_Pin */

GPIO_InitStruct.Pin = PSRAM_NBL0_Pin|PSRAM_NBL1_Pin|PSRAM_A20_Pin|PSRAM_A19_Pin

|D7_Pin|D6_Pin|D12_Pin|D5_Pin

|D11_Pin|D4_Pin|D10_Pin|D9_Pin

|D8_Pin;

GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;

GPIO_InitStruct.Pull = GPIO_NOPULL;

GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;

GPIO_InitStruct.Alternate = GPIO_AF12_FMC;

HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);

 

/*Configure GPIO pin : ARD_D6_Pin */

GPIO_InitStruct.Pin = ARD_D6_Pin;

GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;

GPIO_InitStruct.Pull = GPIO_NOPULL;

GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;

GPIO_InitStruct.Alternate = GPIO_AF2_TIM3;

HAL_GPIO_Init(ARD_D6_GPIO_Port, &GPIO_InitStruct);

 

/*Configure GPIO pin : USART3_RTS_Pin */

GPIO_InitStruct.Pin = USART3_RTS_Pin;

GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;

GPIO_InitStruct.Pull = GPIO_NOPULL;

GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;

GPIO_InitStruct.Alternate = GPIO_AF7_USART3;

HAL_GPIO_Init(USART3_RTS_GPIO_Port, &GPIO_InitStruct);

 

/*Configure GPIO pin : ARD_10_Pin */

GPIO_InitStruct.Pin = ARD_10_Pin;

GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;

GPIO_InitStruct.Pull = GPIO_NOPULL;

GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;

GPIO_InitStruct.Alternate = GPIO_AF5_SPI2;

HAL_GPIO_Init(ARD_10_GPIO_Port, &GPIO_InitStruct);

 

/*Configure GPIO pins : DCMI_D7_Pin DCMI_D5_Pin DCMI_VSYNC_Pin */

GPIO_InitStruct.Pin = DCMI_D7_Pin|DCMI_D5_Pin|DCMI_VSYNC_Pin;

GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;

GPIO_InitStruct.Pull = GPIO_NOPULL;

GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;

GPIO_InitStruct.Alternate = GPIO_AF10_DCMI;

HAL_GPIO_Init(GPIOI, &GPIO_InitStruct);

 

/*Configure GPIO pins : SAI1_SDB_Pin SAI1_FSA_Pin */

GPIO_InitStruct.Pin = SAI1_SDB_Pin|SAI1_FSA_Pin;

GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;

GPIO_InitStruct.Pull = GPIO_NOPULL;

GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;

GPIO_InitStruct.Alternate = GPIO_AF13_SAI1;

HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);

 

/*Configure GPIO pins : OCTOSPIM_P2_IO6_Pin OCTOSPIM_P2_DQS_Pin OCTOSPIM_P2_IO7_Pin OCTOSPIM_P2_CS_Pin */

GPIO_InitStruct.Pin = OCTOSPIM_P2_IO6_Pin|OCTOSPIM_P2_DQS_Pin|OCTOSPIM_P2_IO7_Pin|OCTOSPIM_P2_CS_Pin;

GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;

GPIO_InitStruct.Pull = GPIO_NOPULL;

GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;

GPIO_InitStruct.Alternate = GPIO_AF5_OCTOSPIM_P2;

HAL_GPIO_Init(GPIOG, &GPIO_InitStruct);

 

/*Configure GPIO pins : D2_Pin PSRAM_OE_Pin D3_Pin PSRAM_WE_Pin

PSRAM_WAIT_Pin PSRAM_CLK_Pin PSRAM_NE1_Pin PSRAM_A18_Pin

D1_Pin PSRAM_A17_Pin PSRAM_A16_Pin D15_Pin

D14_Pin */

GPIO_InitStruct.Pin = D2_Pin|PSRAM_OE_Pin|D3_Pin|PSRAM_WE_Pin

|PSRAM_WAIT_Pin|PSRAM_CLK_Pin|PSRAM_NE1_Pin|PSRAM_A18_Pin

|D1_Pin|PSRAM_A17_Pin|PSRAM_A16_Pin|D15_Pin

|D14_Pin;

GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;

GPIO_InitStruct.Pull = GPIO_NOPULL;

GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;

GPIO_InitStruct.Alternate = GPIO_AF12_FMC;

HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);

 

/*Configure GPIO pin : MFX_IRQ_OUT_Pin */

GPIO_InitStruct.Pin = MFX_IRQ_OUT_Pin;

GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING;

GPIO_InitStruct.Pull = GPIO_NOPULL;

HAL_GPIO_Init(MFX_IRQ_OUT_GPIO_Port, &GPIO_InitStruct);

 

/*Configure GPIO pins : DCMI_D3_Pin DCMI_PIXCLK_Pin DCMI_D2_Pin */

GPIO_InitStruct.Pin = DCMI_D3_Pin|DCMI_PIXCLK_Pin|DCMI_D2_Pin;

GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;

GPIO_InitStruct.Pull = GPIO_NOPULL;

GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;

GPIO_InitStruct.Alternate = GPIO_AF10_DCMI;

HAL_GPIO_Init(GPIOH, &GPIO_InitStruct);

 

/*Configure GPIO pin : I2C1_SCL_Pin */

GPIO_InitStruct.Pin = I2C1_SCL_Pin;

GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;

GPIO_InitStruct.Pull = GPIO_NOPULL;

GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;

GPIO_InitStruct.Alternate = GPIO_AF4_I2C1;

HAL_GPIO_Init(I2C1_SCL_GPIO_Port, &GPIO_InitStruct);

 

/*Configure GPIO pin : ARD_D9_Pin */

GPIO_InitStruct.Pin = ARD_D9_Pin;

GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;

GPIO_InitStruct.Pull = GPIO_NOPULL;

GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;

GPIO_InitStruct.Alternate = GPIO_AF3_TIM8;

HAL_GPIO_Init(ARD_D9_GPIO_Port, &GPIO_InitStruct);

 

/*Configure GPIO pins : OCTOPSIM_P2_IO4_Pin OCTOSPIM_P2_IO5_Pin OCTOSPI_P2_IO3_Pin */

GPIO_InitStruct.Pin = OCTOPSIM_P2_IO4_Pin|OCTOSPIM_P2_IO5_Pin|OCTOSPI_P2_IO3_Pin;

GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;

GPIO_InitStruct.Pull = GPIO_NOPULL;

GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;

GPIO_InitStruct.Alternate = GPIO_AF5_OCTOSPIM_P2;

HAL_GPIO_Init(GPIOH, &GPIO_InitStruct);

 

/*Configure GPIO pins : SAI1_MCKA_Pin SAI1_SDA_Pin SAI1_SCKA_Pin */

GPIO_InitStruct.Pin = SAI1_MCKA_Pin|SAI1_SDA_Pin|SAI1_SCKA_Pin;

GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;

GPIO_InitStruct.Pull = GPIO_NOPULL;

GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;

GPIO_InitStruct.Alternate = GPIO_AF13_SAI1;

HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);

 

/*Configure GPIO pin : PSRAM_ADV_Pin */

GPIO_InitStruct.Pin = PSRAM_ADV_Pin;

GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;

GPIO_InitStruct.Pull = GPIO_NOPULL;

GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;

GPIO_InitStruct.Alternate = GPIO_AF12_FMC;

HAL_GPIO_Init(PSRAM_ADV_GPIO_Port, &GPIO_InitStruct);

 

/*Configure GPIO pin : uSD_CMD_Pin */

GPIO_InitStruct.Pin = uSD_CMD_Pin;

GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;

GPIO_InitStruct.Pull = GPIO_NOPULL;

GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;

GPIO_InitStruct.Alternate = GPIO_AF12_SDMMC1;

HAL_GPIO_Init(uSD_CMD_GPIO_Port, &GPIO_InitStruct);

 

/*Configure GPIO pins : uSD_D2_Pin uSD_D3_Pin uSD_CLK_Pin uSD_D0_Pin

uSD_D1_Pin */

GPIO_InitStruct.Pin = uSD_D2_Pin|uSD_D3_Pin|uSD_CLK_Pin|uSD_D0_Pin

|uSD_D1_Pin;

GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;

GPIO_InitStruct.Pull = GPIO_NOPULL;

GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;

GPIO_InitStruct.Alternate = GPIO_AF12_SDMMC1;

HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);

 

/*Configure GPIO pins : USB_OTGFS_ID_Pin USB_OTG_FS_DP_Pin USB_OTGFS_DM_Pin */

GPIO_InitStruct.Pin = USB_OTGFS_ID_Pin|USB_OTG_FS_DP_Pin|USB_OTGFS_DM_Pin;

GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;

GPIO_InitStruct.Pull = GPIO_NOPULL;

GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;

GPIO_InitStruct.Alternate = GPIO_AF10_OTG_FS;

HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

 

/*Configure GPIO pin : JOY_SEL_Pin */

GPIO_InitStruct.Pin = JOY_SEL_Pin;

GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;

GPIO_InitStruct.Pull = GPIO_NOPULL;

GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;

HAL_GPIO_Init(JOY_SEL_GPIO_Port, &GPIO_InitStruct);

 

/*Configure GPIO pin : USB_OTGFS_VBUS_Pin */

GPIO_InitStruct.Pin = USB_OTGFS_VBUS_Pin;

GPIO_InitStruct.Mode = GPIO_MODE_INPUT;

GPIO_InitStruct.Pull = GPIO_NOPULL;

HAL_GPIO_Init(USB_OTGFS_VBUS_GPIO_Port, &GPIO_InitStruct);

 

/*Configure GPIO pins : PSRAM_A2_Pin PSRAM_A1_Pin PSRAM_A0_Pin PSRAM_A3_Pin

PSRAM_A4_Pin PSRAM_A5_Pin PSRAM_A9_Pin PSRAM_A8_Pin

PSRAM_A7_Pin PSRAM_A6_Pin */

GPIO_InitStruct.Pin = PSRAM_A2_Pin|PSRAM_A1_Pin|PSRAM_A0_Pin|PSRAM_A3_Pin

|PSRAM_A4_Pin|PSRAM_A5_Pin|PSRAM_A9_Pin|PSRAM_A8_Pin

|PSRAM_A7_Pin|PSRAM_A6_Pin;

GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;

GPIO_InitStruct.Pull = GPIO_NOPULL;

GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;

GPIO_InitStruct.Alternate = GPIO_AF12_FMC;

HAL_GPIO_Init(GPIOF, &GPIO_InitStruct);

 

/*Configure GPIO pins : ARD_14_Pin ARD_15_Pin */

GPIO_InitStruct.Pin = ARD_14_Pin|ARD_15_Pin;

GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;

GPIO_InitStruct.Pull = GPIO_NOPULL;

GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;

GPIO_InitStruct.Alternate = GPIO_AF4_I2C3;

HAL_GPIO_Init(GPIOG, &GPIO_InitStruct);

 

/*Configure GPIO pin : STMOD_INT_Pin */

GPIO_InitStruct.Pin = STMOD_INT_Pin;

GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING;

GPIO_InitStruct.Pull = GPIO_NOPULL;

HAL_GPIO_Init(STMOD_INT_GPIO_Port, &GPIO_InitStruct);

 

/*Configure GPIO pin : I2C1_SDA_Pin */

GPIO_InitStruct.Pin = I2C1_SDA_Pin;

GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;

GPIO_InitStruct.Pull = GPIO_NOPULL;

GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;

GPIO_InitStruct.Alternate = GPIO_AF4_I2C1;

HAL_GPIO_Init(I2C1_SDA_GPIO_Port, &GPIO_InitStruct);

 

/*Configure GPIO pins : PSRAM_A14_Pin PSRAM_A13_Pin PSRAM_A15_Pin PSRAM_A11_Pin

PSRAM_A12_Pin PSRAM_A10_Pin */

GPIO_InitStruct.Pin = PSRAM_A14_Pin|PSRAM_A13_Pin|PSRAM_A15_Pin|PSRAM_A11_Pin

|PSRAM_A12_Pin|PSRAM_A10_Pin;

GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;

GPIO_InitStruct.Pull = GPIO_NOPULL;

GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;

GPIO_InitStruct.Alternate = GPIO_AF12_FMC;

HAL_GPIO_Init(GPIOG, &GPIO_InitStruct);

 

/*Configure GPIO pins : DFDATIN3_Pin DF_CKOUT_Pin */

GPIO_InitStruct.Pin = DFDATIN3_Pin|DF_CKOUT_Pin;

GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;

GPIO_InitStruct.Pull = GPIO_NOPULL;

GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;

GPIO_InitStruct.Alternate = GPIO_AF6_DFSDM1;

HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);

 

/*Configure GPIO pins : USART3_RX_Pin USART3_TX_Pin */

GPIO_InitStruct.Pin = USART3_RX_Pin|USART3_TX_Pin;

GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;

GPIO_InitStruct.Pull = GPIO_NOPULL;

GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;

GPIO_InitStruct.Alternate = GPIO_AF7_USART3;

HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);

 

/*Configure GPIO pins : ARD_D0_Pin ARD_D1_Pin */

GPIO_InitStruct.Pin = ARD_D0_Pin|ARD_D1_Pin;

GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;

GPIO_InitStruct.Pull = GPIO_NOPULL;

GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;

GPIO_InitStruct.Alternate = GPIO_AF8_LPUART1;

HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);

 

/*Configure GPIO pins : ARD_A2_Pin ARD_A1_Pin */

GPIO_InitStruct.Pin = ARD_A2_Pin|ARD_A1_Pin;

GPIO_InitStruct.Mode = GPIO_MODE_ANALOG_ADC_CONTROL;

GPIO_InitStruct.Pull = GPIO_NOPULL;

HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);

 

/*Configure GPIO pins : ARD_A4_Pin ARD_A0_Pin */

GPIO_InitStruct.Pin = ARD_A4_Pin|ARD_A0_Pin;

GPIO_InitStruct.Mode = GPIO_MODE_ANALOG_ADC_CONTROL;

GPIO_InitStruct.Pull = GPIO_NOPULL;

HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

 

/*Configure GPIO pin : external_led_Pin */

GPIO_InitStruct.Pin = external_led_Pin;

GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;

GPIO_InitStruct.Pull = GPIO_NOPULL;

GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;

HAL_GPIO_Init(external_led_GPIO_Port, &GPIO_InitStruct);

 

/*Configure GPIO pin : STMOD_PWM_Pin */

GPIO_InitStruct.Pin = STMOD_PWM_Pin;

GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;

GPIO_InitStruct.Pull = GPIO_NOPULL;

GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;

GPIO_InitStruct.Alternate = GPIO_AF1_TIM2;

HAL_GPIO_Init(STMOD_PWM_GPIO_Port, &GPIO_InitStruct);

 

/*Configure GPIO pin : SPI2_CS_Pin */

GPIO_InitStruct.Pin = SPI2_CS_Pin;

GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;

GPIO_InitStruct.Pull = GPIO_NOPULL;

GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;

HAL_GPIO_Init(SPI2_CS_GPIO_Port, &GPIO_InitStruct);

 

/*Configure GPIO pins : SPI2_MOSI_Pin SPI2_MISO_Pin SPI2_CLK_Pin */

GPIO_InitStruct.Pin = SPI2_MOSI_Pin|SPI2_MISO_Pin|SPI2_CLK_Pin;

GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;

GPIO_InitStruct.Pull = GPIO_NOPULL;

GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;

GPIO_InitStruct.Alternate = GPIO_AF5_SPI2;

HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);

 

/*Configure GPIO pin : ARD_D5_Pin */

GPIO_InitStruct.Pin = ARD_D5_Pin;

GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;

GPIO_InitStruct.Pull = GPIO_NOPULL;

GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;

GPIO_InitStruct.Alternate = GPIO_AF2_TIM5;

HAL_GPIO_Init(ARD_D5_GPIO_Port, &GPIO_InitStruct);

 

/*Configure GPIO pins : USART2_RX_Pin USART2_TX_Pin */

GPIO_InitStruct.Pin = USART2_RX_Pin|USART2_TX_Pin;

GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;

GPIO_InitStruct.Pull = GPIO_NOPULL;

GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;

GPIO_InitStruct.Alternate = GPIO_AF7_USART2;

HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

 

/*Configure GPIO pin : DSI_TE_Pin */

GPIO_InitStruct.Pin = DSI_TE_Pin;

GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;

GPIO_InitStruct.Pull = GPIO_NOPULL;

GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;

GPIO_InitStruct.Alternate = GPIO_AF11_DSI;

HAL_GPIO_Init(DSI_TE_GPIO_Port, &GPIO_InitStruct);

 

/*Configure GPIO pin : DCMI_HSYNC_Pin */

GPIO_InitStruct.Pin = DCMI_HSYNC_Pin;

GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;

GPIO_InitStruct.Pull = GPIO_NOPULL;

GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;

GPIO_InitStruct.Alternate = GPIO_AF10_DCMI;

HAL_GPIO_Init(DCMI_HSYNC_GPIO_Port, &GPIO_InitStruct);

 

/*Configure GPIO pin : ARD_A3_Pin */

GPIO_InitStruct.Pin = ARD_A3_Pin;

GPIO_InitStruct.Mode = GPIO_MODE_ANALOG_ADC_CONTROL;

GPIO_InitStruct.Pull = GPIO_NOPULL;

HAL_GPIO_Init(ARD_A3_GPIO_Port, &GPIO_InitStruct);

 

/*Configure GPIO pin : MFX_WAKEUP_Pin */

GPIO_InitStruct.Pin = MFX_WAKEUP_Pin;

GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;

GPIO_InitStruct.Pull = GPIO_NOPULL;

GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;

HAL_GPIO_Init(MFX_WAKEUP_GPIO_Port, &GPIO_InitStruct);

 

/*Configure GPIO pin : DFDATIN1_Pin */

GPIO_InitStruct.Pin = DFDATIN1_Pin;

GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;

GPIO_InitStruct.Pull = GPIO_NOPULL;

GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;

GPIO_InitStruct.Alternate = GPIO_AF6_DFSDM1;

HAL_GPIO_Init(DFDATIN1_GPIO_Port, &GPIO_InitStruct);

}

void Error_Handler(void)

{

/* USER CODE BEGIN Error_Handler_Debug */

/* User can add his own implementation to report the HAL error return state */

__disable_irq();

while (1)

{

}

/* USER CODE END Error_Handler_Debug */

}

 

#ifdef USE_FULL_ASSERT

void assert_failed(uint8_t *file, uint32_t line)

{

/* User can add his own implementation to report the file name and line number,

ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */

}

#endif /* USE_FULL_ASSERT */

Associate II
December 18, 2023

i've added the code of main file in the replies

mƎALLEm
ST Technical Moderator
December 18, 2023

You need to have this config for PH4:

GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_LOW;

GPIO_InitStruct.Pin = GPIO_PIN_4;
HAL_GPIO_Init(GPIOH, &GPIO_InitStruct);

To give better visibility on the answered topics, please click "Best answer" on the reply which solved your issue or answered your question.
Associate II
December 18, 2023

ph4 works perfectly fine its pd8 thats not working. thank you so much for helping out

mƎALLEm
ST Technical Moderator
December 18, 2023

Next time please be more specific on the issue .. Your problem description is confusing.

Now for PD8:

- Check the connections using continuity between the LED and GPIOD8.

- external_led_Pin: does it correspond to GPIO_PIN_8?

- external_led_GPIO_Port: does it correspond to GPIOD?

- HAL_GPIO_WritePin(external_led_GPIO_Port, external_led_Pin, GPIO_PIN_RESET); try to toggle it instead of writing a value. I suspect that the external LED is pulled down to GND and not pulled up to the VDD like Green LED.

 

To give better visibility on the answered topics, please click "Best answer" on the reply which solved your issue or answered your question.
mƎALLEm
ST Technical Moderator
December 18, 2023

Could you please verify if PH4 is set for greenled_Pin in CubeMx?

Did you remove the serial resistor connected to the green LED (I think R5)?

To give better visibility on the answered topics, please click "Best answer" on the reply which solved your issue or answered your question.
gbm
Super User
December 18, 2023

Your code in main() does not toggle PD8. Also, if you give a symbolic name to the pin, use that name and port name while setting it.

My STM32 stuff on github - compact USB device stack and more: https://github.com/gbm-ii/gbmUSBdevice