How to enable character match on STM32L431
Hello
I'm using an STM32L431 and trying to enable character match on usart2
MXcube does not manage "MODBUS" modes and the st HAL layer doesn't seem to allow this setting (it allows modbus timout but not character match)
So I try to modify USART_CR2 ADD with character code... impossible !
RM0394 Reference manual tells me : " This bit field can only be written when reception is disabled (RE = 0) or the USART is disabled (UE=0)"
ok I even tested a modification before the MXcube inits
/* USER CODE BEGIN USART2_Init 0 */
huart2.Instance = USART2;
huart2.ReceptionType = HAL_UART_RECEPTION_TOCHARMATCH ;
MODIFY_REG(huart2.Instance->CR2, USART_CR2_ADD , (char)0x0D);
/* USER CODE END USART2_Init 0 */
/* USER CODE BEGIN USART2_Init 1 */
/* USER CODE END USART2_Init 1 */
huart2.Instance = USART2;
huart2.Init.BaudRate = 1200;
huart2.Init.WordLength = UART_WORDLENGTH_7B;
huart2.Init.StopBits = UART_STOPBITS_1;
huart2.Init.Parity = UART_PARITY_NONE;
huart2.Init.Mode = UART_MODE_RX;
huart2.Init.HwFlowCtl = UART_HWCONTROL_NONE;
huart2.Init.OverSampling = UART_OVERSAMPLING_16;
huart2.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;
huart2.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
if (HAL_UART_Init(&huart2) != HAL_OK)
{
Error_Handler();
}C1, C2... all is to 0 RE=0, UE= 0. I do not understand anything anymore
How to modify this register CR2?
How to activate the character match?
Thanks in advance
