# Method for checking TXBL flag

#### yef smith

Joined Aug 2, 2020
84
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){}

#### trebla

Joined Jun 29, 2019
215
I think you must better create a bit mask (0x10) for TXBL bit, then bitwise and it against I2C0_IF register.

#### Papabravo

Joined Feb 24, 2006
14,702
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

#### MrChips

Joined Oct 2, 2009
22,114
Or you can create a structure so that the test becomes

while (! I2C0_IF.TXBL )