How to configure USART for 9bit SPI Master
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2018-08-23 7:08 PM
I'm using CubeMX to configure my STM32F413. I need 9-bit SPI, so I'm using the USART2.
CubeMX is initializing the USART like this:
/* USART2 init function */
static void MX_USART2_Init(void)
{
husart2.Instance = USART2;
husart2.Init.BaudRate = 100000;
husart2.Init.WordLength = USART_WORDLENGTH_9B;
husart2.Init.StopBits = USART_STOPBITS_1;
husart2.Init.Parity = USART_PARITY_NONE;
husart2.Init.Mode = USART_MODE_TX;
husart2.Init.CLKPolarity = USART_POLARITY_HIGH;
husart2.Init.CLKPhase = USART_PHASE_1EDGE;
husart2.Init.CLKLastBit = USART_LASTBIT_DISABLE;
if (HAL_USART_Init(&husart2) != HAL_OK)
{
_Error_Handler(__FILE__, __LINE__);
}
}
I've tried every combination of Polarity, Phase, and "Clock Last Bit".
The problem I'm seeing is that the is driven out before the clock starts running. It's approximately one clock cycle ahead of the clock:
How do I configure the USART2 for 9-bit SPI Master?
Thanks,
Matt
This discussion is locked. Please start a new topic to ask your question.
0 REPLIES 0
