Hi,
I'm wondering what is the proper way to clear TDRE and TC flags.
According to the reference manual, in the ISR we shall read the UARTx_S1 and then write to UARTx_D to clear the flags.
But if there isn't more data to be sent, then writing to D register will cause NULL or what ever values to be shifted out.
To correct that I'm doing, disable transmission [TE], write to D and then perform a TXFLUSH.
Is this the correct way or there is a better one?
Regards,
Paulo
Hi Paulo,
Seems you want to use these two interrupts to send data, right? if so, in the ISR, S1 will be read first and then writing to the D register, and when there is no more data to be sent, the ISR may simply disable the IRQ, just left the status bit assert as it is the default (reset) state for this bit. and the same for TC bit/interrrupt.
Hope that helps,
B.R
Kan
Hi Kan_Li,
Thanks for the reply. So what you saying is i shall disable the ISR in the NVIC and leave the Interrupt flags alone. Then when i have more data to send i just activate the ISR in the NVIC again, and the ISR takes it from there.
Sounds good, thanks for the help.
Regards,
Paulo