This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

A bug in ST's firmware library?

People,
please do forgive me if I'm wrong - my head hurts, have been debugging all day long and I may have found the problem!
See pevious threads related to UART interrupts. I think I never acknowledged the interrupt because

void UART_ClearITPendingBit(UART_TypeDef* UARTx, u16 UART_IT)
{
  /* Clear the specified interrupt */
  UARTx->ICR &= UART_IT;
}

does not write a 1 to acknowledge the receive interrupt if ICR is already 0 when the call occurs.
if you do this:

UART0->ICR = 0x10 ;

the interrupt is acknowledge (yes, I know this might overwrite other bits...)
Please forgive me if I oversee something (did read the specification, too much actually...), I am "kapoot" but happy I managed to more on a little!

Parents
  • Per,
    the purpose of the "ClearITPendingBit" is to clear a flag, including the interrupt receive flag. the point is, that clearing the interrupt occurs by writing a "1" (see STR9 datasheet :) ).
    it should be a logical OR instead of a AND.
    but guess what I found in the latest library downloaded from ST's site?

    void UART_ClearITPendingBit(UART_TypeDef* UARTx, u16 UART_IT)
    {
      /* Clear the specified interrupt */
      UARTx->ICR = UART_IT;
    }
    

    not good yet, but will work a little better.
    that's it. I'm going to bed!

Reply
  • Per,
    the purpose of the "ClearITPendingBit" is to clear a flag, including the interrupt receive flag. the point is, that clearing the interrupt occurs by writing a "1" (see STR9 datasheet :) ).
    it should be a logical OR instead of a AND.
    but guess what I found in the latest library downloaded from ST's site?

    void UART_ClearITPendingBit(UART_TypeDef* UARTx, u16 UART_IT)
    {
      /* Clear the specified interrupt */
      UARTx->ICR = UART_IT;
    }
    

    not good yet, but will work a little better.
    that's it. I'm going to bed!

Children
  • I disagree, the ST library as I see it is correct - It makes sense to write:

    UARTx->ICR = UART_IT

    and not logical or (read/write instruction seq.)

    writing the location does exactly what the manual says - SET the BIT to clear the flag - by doing an 'OR' operation, you may pick up other flags and clear those as well when not intending to.