2019-04-06 09:22 PM
Dear Members,
I changed my clock from MSI to HSI but my SPI and UART baudrate becoming wrong,
What do I miss here ?
thanks
2019-04-07 08:50 PM
Please correct my configuration ?
====
void MX_USART3_UART_Init(void)
{
huart3.Instance = USART3;
huart3.Instance->BRR=34;
huart3.Init.BaudRate = 115200;
huart3.Init.WordLength = UART_WORDLENGTH_8B;
huart3.Init.StopBits = UART_STOPBITS_1;
huart3.Init.Parity = UART_PARITY_NONE;
huart3.Init.Mode = UART_MODE_TX_RX;
huart3.Init.HwFlowCtl = UART_HWCONTROL_NONE;
huart3.Init.OverSampling = UART_OVERSAMPLING_8;
if (HAL_UART_Init(&huart3) != HAL_OK)
{
Error_Handler();
}
}
=====
I read from :
2019-04-07 09:07 PM
I would decompose the clocks as seen of the AHB/APB. Print them out a USART that is working. Use the SWV channel if available.
HAL_UART_Init() is going to overwrite the value you put in BBR, and BBR might well be locked when the USART is enabled.
What bit rate do you see if you send 0x55 data patterns? You see anything at the pins?
Assuming the L152, any board we might be familiar with?
Drops into Error_Handler() ?
2019-04-08 12:20 AM
Assuming the L152, any board we might be familiar with?
Nucleo STM32L152RE
Drops into Error_Handler() ?
printf on my Error_Handler ? It's working with uart2, which is talking with GPS, but uart3 not working on a proper speed ??
0x55 pattern to uart3 ? and ping back ?
thanks
2019-04-08 12:21 AM
decomposing ? sounds advance for me, trying to figure it out on implementing it ...
Thanks
2019-04-08 01:34 AM
baudrate 115200 clock = 2.097Mhz
Send 0x55, code
printf("0x55");
printf("\r\n");
output :
clock = 32Mhz,
baudrate = 115200
output :
any clues ? thanks
2019-04-08 03:49 AM
On STM32CubeMX, it said, UART3 has a conflict, does it matter ?
2019-04-08 04:12 AM
while (1) putchar(0x55);
Use a scope so you can measure bit timing.
2019-04-08 07:43 AM
Sometime it's easier to check on the datasheet alternate function table.
Anyway only one alternate "output" can be activated (it's a mux) at anytime.
Do check the GPIO registers in debug mode HW register view.
Check on GPIO MODER and AF registers for this pin.
2019-04-08 08:52 AM
Sorry I don't use CubeMX, what does the Reference Manual suggest are the connectivity modes here, and what pin conflicts are there. As presented you're showing with work with clock source X and failing with clock source Y
So I'd focus on the clock trees and sources, and determine is the clock routing is broken, for example you've selected a source that isn't present, or is at a different frequency.
Outputting a stream of 'U' characters (0x55) gives you something to measure on a scope. ie does something come out of the pin? is it the right frequency?
Try doubling or halving the baud rate you program whilst leaving the terminal at 115200. See data then?
2019-04-08 01:57 PM
Starts by doing simple stuff
Like
printf("Core=%d, %d MHz\n", SystemCoreClock, SystemCoreClock / 1000000);
printf("HCLK=%d\n", HAL_RCC_GetHCLKFreq());
printf("APB1=%d\n", HAL_RCC_GetPCLK1Freq());
printf("APB2=%d\n", HAL_RCC_GetPCLK2Freq());
Outputting internal clocks via PA8 MCO and scoping them.
And then looking at RCC and peripheral settings in debugger, finding settings in the chain that look/are wrong.