2016-07-22 03:03 AM
In the function:
void USART_SetReceiverTimeOut(USART_TypeDef* USARTx, uint32_t USART_ReceiverTimeOut)
The code:/* Clear the receiver Time Out value by clearing the RTO[23:0] bits in the RTOR register */
USARTx->RTOR &= (uint32_t)~((uint32_t)USART_RTOR_RTO); /* Set the receiver Time Out value by setting the RTO[23:0] bits in the RTOR register */ USARTx->RTOR |= USART_ReceiverTimeOut;The problem is that in the datasheet, in the page 701, says:RTOR can be written on the fly. If the new value is lower than or equal to the counter, the
RTOF flag is set.Then went I call to this function of the interrupt routine to assign a new timeout value it generate a new interrupt on every call.To solve it, this function have to be changed, saving the initial value of the register in a local variable, change the value and store it back to the register. #usart #stm322016-07-22 06:22 AM
Hi sole.toni,
Can you clarify more your feedback . I suggest you make you mmodification that you proposed into the function and share with us the modified function's code. Thanks -Hannibal-2016-07-28 01:40 AM
This is the function with a fix:
void USART_SetReceiverTimeOut(USART_TypeDef* USARTx, uint32_t USART_ReceiverTimeOut)
{ uint32_t rtmask; /* Check the parameters */ assert_param(IS_USART_123_PERIPH(USARTx)); assert_param(IS_USART_TIMEOUT(USART_ReceiverTimeOut)); /* Copy RTOR register to a temporal variable with the RTO[23:0] bits cleared */ rtmask = USARTx->RTOR & (uint32_t)~((uint32_t)USART_RTOR_RTO); /* Update the RTOR register with a new value on RTO[23:0] bits */ USARTx->RTOR = rtmask | USART_ReceiverTimeOut;}2016-07-28 01:41 AM
This is the function with a fix:
void USART_SetReceiverTimeOut(USART_TypeDef* USARTx, uint32_t USART_ReceiverTimeOut)
{ uint32_t rtmask; /* Check the parameters */ assert_param(IS_USART_123_PERIPH(USARTx)); assert_param(IS_USART_TIMEOUT(USART_ReceiverTimeOut)); /* Copy RTOR register to a temporal variable with the RTO[23:0] bits cleared */ rtmask = USARTx->RTOR & (uint32_t)~((uint32_t)USART_RTOR_RTO); /* Update the RTOR register with a new value on RTO[23:0] bits */ USARTx->RTOR = rtmask | USART_ReceiverTimeOut;}2016-07-29 11:04 AM
Hi sole.toni,
Thanks for the feedback. I report this internally. -Hannibal-