2018-01-17 04:16 AM
Hello. I have a problem with UART3 on STM32F4Discovery kit. There is STM32F407VG. And I try send string, but program sendin wrong string. I use crystal 8MHz on HSE.
In files you can see my code.
UART:
https://paste.ofcode.org/jqNikWZbRQvYrAsL8VnkrL
CLOCK:
https://paste.ofcode.org/3bEa2czziJ2BphWPMpjK8Ut
Main:
https://paste.ofcode.org/GjGuUP3MK2RqXaj8KDtB9i
Any idea, what is wrong?
#stm32f4discovery #usart2018-01-17 04:27 AM
but program sendin wrong string
How do you know? How did you observe the output? What do you see?
JW
2018-01-17 05:18 AM
Enable the clock BEFORE touching pins
LL_AHB1_GRP1_EnableClock(LL_AHB1_GRP1_PERIPH_GPIOD); // ENABLE CLOCK FIRST, SYNCHRONOUS LOGIC AHEAD
LL_GPIO_SetAFPin_8_15(GPIOD, LL_GPIO_PIN_8, LL_GPIO_AF_7);
LL_GPIO_SetAFPin_8_15(GPIOD, LL_GPIO_PIN_9, LL_GPIO_AF_7);2018-01-17 05:45 AM
Here is my screenshots from programs (putty and hercules). In putty is more then one ''hello''. In herkules is one ''hello''.
2018-01-17 05:56 AM
Set the terminals to display binary/hexadecimal, as a minimum. If these two can't do it, get Bray's and/or realterm.
Any chance to get a logic analyzer or oscilloscope and observe the lines?
Btw. what's the hardware? Are there any RS232-transceiveres?
JW
2018-01-17 06:15 AM
How have you verified the baud rate?
'garbage' like that is generally due to wrong baud rate...
2018-01-17 06:17 AM
See:
- only yesterday.2018-01-17 11:01 PM
Ok. I try change speed of UART. And I have wrong clock. I set in my UART 115200, but real speed is 38400.
I try change clock, but it isn't working:
//External CLOCK: 8MHz
void SystemClock_Config(void)
{ LL_FLASH_SetLatency(LL_FLASH_LATENCY_5);if(LL_FLASH_GetLatency() != LL_FLASH_LATENCY_5)
{ Error_Handler(); } LL_PWR_SetRegulVoltageScaling(LL_PWR_REGU_VOLTAGE_SCALE1);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, 168, 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_4);
LL_RCC_SetAPB2Prescaler(LL_RCC_APB2_DIV_2);
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(168000000);LL_SYSTICK_SetClkSource(LL_SYSTICK_CLKSOURCE_HCLK);
LL_SetSystemCoreClock(168000000);
}2018-01-17 11:14 PM
Ok. Problem was with settings clock.
I use internal HSI and problem was solved.