cancel
Showing results for 
Search instead for 
Did you mean: 

Bug report: stm32f0xx_usart.c v1.5.0

toni
Associate II
Posted on July 22, 2016 at 12:03

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 #stm32
4 REPLIES 4
Walid FTITI_O
Senior II
Posted on July 22, 2016 at 15:22

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-

toni
Associate II
Posted on July 28, 2016 at 10:40

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;

}

toni
Associate II
Posted on July 28, 2016 at 10:41

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;

}

Walid FTITI_O
Senior II
Posted on July 29, 2016 at 20:04

Hi sole.toni,

Thanks for the feedback. I report this internally.

-Hannibal-