For what I can see, those two codes make totally different things.
In you first example, TXREG, whatever it is, is assigned with a differet value every time TRMT becomes false. Later, LE becomes 1, NOP() is invoked three times, LE is turned into 0, and the function ends.
In your second example, TXREG is assigned with the value of gBuffer1[0] once, then the function exits.
Enoizat and helpinghand, I agree with both of you. I decided to stick with the first piece of code. Switch method is not that necessary. Thank you for your help!
void
wait_until_TSR_empty() // or whatever
while (!TRMT)
/* do nothing */;
}
void
updateLEDs(void)
{
wait_until_TSR_empty();
for (int i = 0 i < 4; ++i) {
TXREG = gBuffer1[ i ];
wait_until_TSR_empty();
}
LE = 1;
NOP(); NOP(); NOP();
LE = 0;
}