Closed maribeiro closed 10 months ago
I managed to make it work. It was a problem with the clocks. Interesting thing is that using STM32CubeIDE it runs fine with that clock. After fiddling with the clocks a bit more, I managed to get it working on ArduinoIDE with the following clock:
extern "C" 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) != HAL_OK)
{
Error_Handler();
}
/** Initializes the RCC Oscillators according to the specified parameters
* in the RCC_OscInitTypeDef structure.
*/
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI48|RCC_OSCILLATORTYPE_HSE;
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
RCC_OscInitStruct.HSI48State = RCC_HSI48_ON;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
RCC_OscInitStruct.PLL.PLLM = 1;
RCC_OscInitStruct.PLL.PLLN = 8;
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
RCC_OscInitStruct.PLL.PLLQ = RCC_PLLQ_DIV2;
RCC_OscInitStruct.PLL.PLLR = RCC_PLLR_DIV4;
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_0) != HAL_OK)
{
Error_Handler();
}
}
.Thanks. So I close it.
Describe the bug Enabling the USB CDC (so that a virtual com port shows when i plug a usb to my board) seems to break the application. [I also tried the exact same code (minus the clock def) with a F407disco board (and although it's a different uP) it works fine! ]
To Reproduce Just compile and upload the code (with USB Support CDC enabled) with a ST-LINK v2 :
As soon as I enable the USB Support: CDC , the application seems to not run anymore. No LED blinking and no Virtual COM Port appear. If i just comment the Serial related lines and revert the USB Support to: 'None', the LED blinks fine.
Expected behavior A new Virtual Com port should appear when plugging the USB to the STM32L4P5 board and the LED should also blink.
Screenshots
Desktop (please complete the following information):
Board (please complete the following information):
Additional context Using the exact same board with STM32CubeIDE and same clock configuration, the Virtual COM port shows correctly and the remaining code (PB8 toggle - blink) runs as expected. Log with verbose output (compile and upload) : https://pastebin.com/DTvU40un