2018-05-08 07:38 AM
HI
Im using Nucleo144 L4R5ZI board, using CubeMX i have generated the code to enabling the LPUART1 which the ST-Link is enabled for virtual COM port.
when i just took a simple private variable im trying to see the message on lpuart1 using HAL_UART_Transmit, nothing is being displayed.
Tried Debugging it halts the system on HAL_Init().
May be with the code generated or so??
When i tried with the example provided for the board,PWR/PWR_ModesSelection/Src it works fine, more over this code uses _GNU-...putchar ....redirecting to UART......and making the printf enable.
But i tried the basic way of getting the message on virtual COM port.
May be something missing in the code which is generated by CubeMX.
Thanks
Phanirajkiran
#cubemxSolved! Go to Solution.
2018-05-09 03:54 AM
Hi Clive,
As you pointed out before, yes it is regarding the SystemClock_Config, in cubemx it picksup RCC_OSCILLATORTYPE_HSE.
Now i have fixed it up.
Thanks for your support and leads in directing towards the problem.
Thanks
Phanirajkiran
2018-05-08 03:06 PM
>>May be something missing in the code which is generated by CubeMX.
Quite probably, not using CubeMX here.
Would look at PLLM setting, GPIO Bank G power enable, and LPUART prescaler
2018-05-08 11:58 PM
Hi
These are the below settings where working COM port:
Working example code:
CubeMX Generated code:
Where looked at the CubeMX generated code in SystemClock_Config
It uses the
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
And the peripheral clock is also present.
/**
* @brief System Clock Configuration * @retval None */void SystemClock_Config(void){RCC_OscInitTypeDef RCC_OscInitStruct;
RCC_ClkInitTypeDef RCC_ClkInitStruct; RCC_PeriphCLKInitTypeDef PeriphClkInit;/**Configure the main internal regulator output voltage
*/ if (HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE1_BOOST) != HAL_OK) { _Error_Handler(__FILE__, __LINE__); }/**Initializes the CPU, AHB and APB busses clocks
*/ RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; RCC_OscInitStruct.HSEState = RCC_HSE_BYPASS; RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; RCC_OscInitStruct.PLL.PLLN = 30; 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(__FILE__, __LINE__); }/**Initializes the CPU, AHB and APB busses 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_DIV2; RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5) != HAL_OK)
{ _Error_Handler(__FILE__, __LINE__); }PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USART3|RCC_PERIPHCLK_LPUART1
|RCC_PERIPHCLK_USB; PeriphClkInit.Usart3ClockSelection = RCC_USART3CLKSOURCE_PCLK1; PeriphClkInit.Lpuart1ClockSelection = RCC_LPUART1CLKSOURCE_PCLK1; PeriphClkInit.UsbClockSelection = RCC_USBCLKSOURCE_PLLSAI1; PeriphClkInit.PLLSAI1.PLLSAI1Source = RCC_PLLSOURCE_HSE; PeriphClkInit.PLLSAI1.PLLSAI1M = 1; PeriphClkInit.PLLSAI1.PLLSAI1N = 12; PeriphClkInit.PLLSAI1.PLLSAI1P = RCC_PLLP_DIV2; PeriphClkInit.PLLSAI1.PLLSAI1Q = RCC_PLLQ_DIV2; PeriphClkInit.PLLSAI1.PLLSAI1R = RCC_PLLR_DIV2; PeriphClkInit.PLLSAI1.PLLSAI1ClockOut = RCC_PLLSAI1_48M2CLK; if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK) { _Error_Handler(__FILE__, __LINE__); }/**Configure the Systick interrupt time
*/ HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/1000);/**Configure the Systick
*/ HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK);/* SysTick_IRQn interrupt configuration */
HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0);}When i tired to debug the code which CubeMX generated, when it enters into the Debug mode, Target enters into the Halt state and
Waits for debug trigger to HAL_RCC_OscConfig
And prompt pauses at 499 line to READ the RCC and RCC_CR are at the Tick.
Thanks
Phanirajkiran
2018-05-09 03:27 AM
I would do this to insure the structures were clear/clean,
void SystemClock_Config(void)
{RCC_OscInitTypeDef RCC_OscInitStruct = {0};
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; RCC_PeriphCLKInitTypeDef PeriphClkInit = {0};...
2018-05-09 03:54 AM
Hi Clive,
As you pointed out before, yes it is regarding the SystemClock_Config, in cubemx it picksup RCC_OSCILLATORTYPE_HSE.
Now i have fixed it up.
Thanks for your support and leads in directing towards the problem.
Thanks
Phanirajkiran