cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F4Discovery and UART3 problem

Pilous Droip
Senior
Posted on January 17, 2018 at 13:16

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 #usart
8 REPLIES 8
Posted on January 17, 2018 at 13:27

but program sendin wrong string

How do you know? How did you observe the output? What do you see?

JW

Posted on January 17, 2018 at 14:18

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);
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on January 17, 2018 at 13:45

Here is my screenshots from programs (putty and hercules). In putty is more then one ''hello''. In herkules is one ''hello''.

0690X00000604GWQAY.jpg0690X00000603yjQAA.jpg
Posted on January 17, 2018 at 13:56

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

Posted on January 17, 2018 at 14:15

How have you verified the baud rate?

'garbage' like that is generally due to wrong baud rate...

Posted on January 17, 2018 at 14:17

See: 

https://community.st.com/0D70X000006SrgUSAS

  - only yesterday.
Pilous Droip
Senior
Posted on January 18, 2018 at 08:01

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);

}
Pilous Droip
Senior
Posted on January 18, 2018 at 08:14

Ok. Problem was with settings clock.

I use internal HSI and problem was solved.