2013-07-04 04:33 AM
Hi all,
The documentation of the ''GetITStatus'' function, as found in the file 'stm32f10x_uasrt.c'', describes the functionality as follows: ''Checks whether the specified USART interrupt has occurred or not.'' However, when I follow what happens why I call GetITStatus(UART1, USART_IT_TXE), it appears that it simply returns bit 7 of CR1 (TXEIE) which, according to the STM32 reference manual (RM0008), is the ''TXE interrupt enable''. It seems these are two different things; the GetITStatus() documentation claims that the bit returns if the interrupt *has happened*, while the reference manual gives the meaning as: the interrupt is enabled (i.e., it *can happen*). Can anyone explain which of these two interpretations is the correct one? #uart2013-07-04 05:11 AM
If I follow it correctly it returns SET when two bits are set TXE in SR and TXEIE in CR1.
It seems the only way to check if the interrupt has occurred.2013-07-04 05:39 AM
USART_GetITStatus() gets the flagging from USARTx->SR, and masks that with if the bits are actually enabled.
2013-07-04 07:03 AM
> If I follow it correctly it returns SET when two bits are set TXE in SR and TXEIE in CR1.
Yes, on second inspection that appears to be what it does: anding the appropriate bits from the SR and the appropriate CR{1|2|3}. This means that the documented behavior (''Checks whether the specified USART interrupt has occurred or not'') is not quite correct. For example, writing to DR just before executing ''USART_GetITStatus()'' will make it return false, even if we're actually handling the TXE interrupt.