Uart clock problem - Printable Version +- EmBitz (https://www.embitz.org/forum) +-- Forum: IDE (https://www.embitz.org/forum/forum-1.html) +--- Forum: Using EmBitz (https://www.embitz.org/forum/forum-2.html) +--- Thread: Uart clock problem (/thread-109.html) |
Uart clock problem - Peterb - 31-12-2021 Hi, Thank you for the new Embitz version! I used v1 for F103 with success, and now tried for F446RE: I have a code, developed with CubeIDE with LL driver on a CubeMX gererated base. Finally it has some very strange runtime problem, if I build with CubeIDE, so I tried to build with the Embitz 2. It was success and works fine, but one strange thing: both UART1 and UART3 has exactly 1/3 baudrate of the defined, while I didn't change the original init functions. It means, the defined 115200 works as 38400, and 19200 works as 6400. While the frequency of TIM1, TIM2, TIM3 remain OK, so the SYSCLK seems remain 72MHz. Has somebody any idea? These are the MX generated init codes: If I change below the 115200 to 345600, the real baudrate will be 115200 void SystemClock_Config(void) { LL_FLASH_SetLatency(LL_FLASH_LATENCY_2); while(LL_FLASH_GetLatency()!= LL_FLASH_LATENCY_2) { } LL_PWR_SetRegulVoltageScaling(LL_PWR_REGU_VOLTAGE_SCALE3); LL_PWR_DisableOverDriveMode(); LL_RCC_HSE_Enable(); /* Wait till HSE is ready */ while(LL_RCC_HSE_IsReady() != 1) { } LL_RCC_PLL_ConfigDomain_SYS(LL_RCC_PLLSOURCE_HSE, LL_RCC_PLLM_DIV_4, 72, LL_RCC_PLLP_DIV_2); LL_RCC_PLL_Enable(); /* Wait till PLL is ready */ while(LL_RCC_PLL_IsReady() != 1) { } LL_RCC_SetAHBPrescaler(LL_RCC_SYSCLK_DIV_1); LL_RCC_SetAPB1Prescaler(LL_RCC_APB1_DIV_2); LL_RCC_SetAPB2Prescaler(LL_RCC_APB2_DIV_1); LL_RCC_SetSysClkSource(LL_RCC_SYS_CLKSOURCE_PLL); /* Wait till System clock is ready */ while(LL_RCC_GetSysClkSource() != LL_RCC_SYS_CLKSOURCE_STATUS_PLL) { } LL_Init1msTick(72000000); LL_SetSystemCoreClock(72000000); LL_RCC_SetTIMPrescaler(LL_RCC_TIM_PRESCALER_TWICE); } static void MX_USART1_UART_Init(void) { /* USER CODE BEGIN USART1_Init 0 */ /* USER CODE END USART1_Init 0 */ LL_USART_InitTypeDef USART_InitStruct = {0}; LL_GPIO_InitTypeDef GPIO_InitStruct = {0}; /* Peripheral clock enable */ LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_USART1); LL_AHB1_GRP1_EnableClock(LL_AHB1_GRP1_PERIPH_GPIOA); /**USART1 GPIO Configuration PA9 ------> USART1_TX PA10 ------> USART1_RX */ GPIO_InitStruct.Pin = LL_GPIO_PIN_9|LL_GPIO_PIN_10; GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_VERY_HIGH; GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; GPIO_InitStruct.Alternate = LL_GPIO_AF_7; LL_GPIO_Init(GPIOA, &GPIO_InitStruct); /* USART1 interrupt Init */ NVIC_SetPriority(USART1_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(),0, 0)); NVIC_EnableIRQ(USART1_IRQn); /* USER CODE BEGIN USART1_Init 1 */ /* USER CODE END USART1_Init 1 */ USART_InitStruct.BaudRate = 115200; USART_InitStruct.DataWidth = LL_USART_DATAWIDTH_8B; USART_InitStruct.StopBits = LL_USART_STOPBITS_1; USART_InitStruct.Parity = LL_USART_PARITY_NONE; USART_InitStruct.TransferDirection = LL_USART_DIRECTION_TX_RX; USART_InitStruct.HardwareFlowControl = LL_USART_HWCONTROL_NONE; USART_InitStruct.OverSampling = LL_USART_OVERSAMPLING_16; LL_USART_Init(USART1, &USART_InitStruct); LL_USART_ConfigAsyncMode(USART1); LL_USART_Enable(USART1); /* USER CODE BEGIN USART1_Init 2 */ LL_USART_EnableIT_RXNE (USART1); /* USER CODE END USART1_Init 2 */ } RE: Uart clock problem - embitz - 03-01-2022 Did you compare the register values in the SVD viewer? There must be something different. |