Method for checking TXBL flag

Thread Starter

yef smith

Joined Aug 2, 2020
756
Hello,While we are sending data TXBL is zero,onle the sending is done TXBL bit goes 1.
Can i check the 4th bit in this way shown bellow?
Thanks.
Code:
 while(I2C0->IF[4]!=1){}
1603204189418.png
 

Papabravo

Joined Feb 24, 2006
21,228
I don't think so. That is not one of the usual methods available for checking bits. How you do it is compiler dependent, it may or may not be in the latest C standard, but it was never addressed in the previous ones.
The semantics of your statement suggest an array of some type (byte, char, int ...) pointed to by I2C0

while (((I2C0->IF) & (1<<4)) == 0)

would be closer to the correct syntax and semantics, UNLESS your specific compiler provides a method for picking a specific bit out of a word, something like
I2C0->IF.4
 
Top