2023-01-19 11:34 AM
I have a board P-Nucleo55WB and I have to receive data from usart syncronized with external clock.
Is it possible?
I tried to configure with CubeMX as Syncronized Slave and I see USART1_CK enabled, but this pin is not used for receive the external clock, is it correct?
In the generated code I see this
/*-------------------------- USART BRR Configuration -----------------------*/
/* BRR is filled-up according to OVER8 bit setting which is forced to 1 */
USART_GETCLOCKSOURCE(husart, clocksource);
switch (clocksource)
{
case USART_CLOCKSOURCE_PCLK2:
pclk = HAL_RCC_GetPCLK2Freq();
usartdiv = (uint32_t)(USART_DIV_SAMPLING8(pclk, husart->Init.BaudRate, husart->Init.ClockPrescaler));
break;
case USART_CLOCKSOURCE_HSI:
usartdiv = (uint32_t)(USART_DIV_SAMPLING8(HSI_VALUE, husart->Init.BaudRate, husart->Init.ClockPrescaler));
break;
case USART_CLOCKSOURCE_SYSCLK:
pclk = HAL_RCC_GetSysClockFreq();
usartdiv = (uint32_t)(USART_DIV_SAMPLING8(pclk, husart->Init.BaudRate, husart->Init.ClockPrescaler));
break;
case USART_CLOCKSOURCE_LSE:
usartdiv = (uint32_t)(USART_DIV_SAMPLING8(LSE_VALUE, husart->Init.BaudRate, husart->Init.ClockPrescaler));
break;
default:
ret = HAL_ERROR;
break;
}
so clock source can not be external, what is the function of the USART1_CK GPIO?
Solved! Go to Solution.
2023-01-23 02:18 AM
Hi @juvann
When operating in Slave mode, the Clock will be provided by the device you are connected to (i.e. the remote side operating as Master). So the baudrate setting on slave side will not be taken into account (you could leave a default value as 9600 in your CubeMx configuration, but it will not be used).
Regards
2023-01-19 11:49 PM
Hi @juvann
In Synchronous mode, if USART is configured in Slave mode, USARTx_CK is pin is the input of the USART. It should then be connected to CK pin of the Master.
Regards
2023-01-21 07:56 AM
Hi @Guenael Cadier ,
thank you for your reply.
Why in the code generated by CubeMx the source code can't be external?
How should I configure the baudrate when the clock is external?
Maybe is better remove a part of generate code and set uart div manually.
Regards
2023-01-23 02:18 AM
Hi @juvann
When operating in Slave mode, the Clock will be provided by the device you are connected to (i.e. the remote side operating as Master). So the baudrate setting on slave side will not be taken into account (you could leave a default value as 9600 in your CubeMx configuration, but it will not be used).
Regards