GPIO toggling led not working after use Bypass clock source

Anything not related to STM32
Post Reply
ahsanu
Posts: 7
Joined: Wed Jul 27, 2022 1:14 pm

GPIO toggling led not working after use Bypass clock source

Post by ahsanu »

hey all,

recently i started new project (STM32F407VGT6) use USB FS with stm32 CUBE IDE, i choose clock source from bypass(cause usb cant use internal clock), after code is generated by cube ide, i check by blink led on PA1, but the led is not blinking at all. but after i disable USB and change clock source to internal, led is blinking as it should.

am i wrong with configuration of USB and clock source?, (i already watch usb tutorial on stm32 youtube channel also)

i believe my code is not wrong (cause its just basic blink led):

here is my board: https://github.com/mcauser/MCUDEV_DEVEBOX_F407VGT6

Code: Select all

int main(void)
{
  /* USER CODE BEGIN 1 */

  /* USER CODE END 1 */

  /* MCU Configuration--------------------------------------------------------*/

  /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  HAL_Init();

  /* USER CODE BEGIN Init */

  /* USER CODE END Init */

  /* Configure the system clock */
  SystemClock_Config();

  /* USER CODE BEGIN SysInit */

  /* USER CODE END SysInit */

  /* Initialize all configured peripherals */
  MX_GPIO_Init();
  /* USER CODE BEGIN 2 */

  HAL_GPIO_WritePin(led_GPIO_Port, led_Pin, GPIO_PIN_RESET);

  /* USER CODE END 2 */

  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
  while (1)
  {
	  HAL_GPIO_TogglePin(led_GPIO_Port, led_Pin);
	  HAL_Delay(100);
    /* USER CODE END WHILE */

    /* USER CODE BEGIN 3 */
  }
  /* USER CODE END 3 */
}
any help is really appreciated, thanks
User avatar
fpiSTM
Posts: 1723
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: GPIO toggling led not working after use Bypass clock source

Post by fpiSTM »

This board has an HSE so do not use bypass. Simply define crystal ans set correctly HSE value.
ahsanu
Posts: 7
Joined: Wed Jul 27, 2022 1:14 pm

Re: GPIO toggling led not working after use Bypass clock source

Post by ahsanu »

thanks for your reply, after i change the setting (use crystal/ceramic resonator), my code is working.
but its just working when i use gpio and usb only, but i need other peripheral also.

i also try to make new project with only usb and gpio enabled, its working, but after i change to my other project with some peripheral enabled, usb and toggling gpio is not working, is peripheral usage with usb have limitation (i need disabled some peripheral maybe?)

i also enabled serial wire for debuging (does this have any effect?)

iam curious if initialization sequence is have effect, cause after i change the init sequence my computer can recognize the usb i plugged in (at least its can detect it) but still go error like screenshot below
Image

Code: Select all

/* Initialize all configured peripherals */
  MX_GPIO_Init();
  MX_USB_DEVICE_Init();  //<===== this function
  MX_ADC1_Init();
  MX_I2C1_Init();
  MX_SDIO_SD_Init();
  MX_SPI1_Init();
  MX_USART3_UART_Init();
  MX_TIM2_Init();
                          // <======= first is over here
  /* USER CODE BEGIN 2 */
  
after i disabled other init function the code is work, but after i re-enable it its back to not working again.

here is screenshot after i disabled other init code (my pc can recognize stm usb)

Image

Code: Select all

  MX_GPIO_Init();
//  MX_ADC1_Init();
//  MX_I2C1_Init();
//  MX_SDIO_SD_Init();
//  MX_SPI1_Init();
//  MX_USART3_UART_Init();
//  MX_TIM2_Init();
  MX_USB_DEVICE_Init();
whats wrong with my settings?
thanks
User avatar
fpiSTM
Posts: 1723
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: GPIO toggling led not working after use Bypass clock source

Post by fpiSTM »

You also opened an issue on the STM32CubeF4 GitHub:
https://github.com/STMicroelectronics/S ... issues/153

The OP has been answered, you do not have a Bypass HSE so simply used crystal HSE.
It seems you didn't properly configure your project but we cannot help based on input information.
This forum is mainly dedicated to STM32 support within Arduino which is not the case here so you should better complete the opened issue with all relevant information to get help.
ahsanu
Posts: 7
Joined: Wed Jul 27, 2022 1:14 pm

Re: GPIO toggling led not working after use Bypass clock source

Post by ahsanu »

ok i will continoue on github, thanks.
Post Reply

Return to “Off topic”