> the loop is while(STA != 0x08).
This is a little confusion: for me, STA stands for a bit in the
control register (I2CONSET) and it has the constant value 0x20. A
while loop comparing two different constants will indeed be an endless
loop.
But perhaps, you are referring to STA to mean the state register
(I2STAT). There may be a number of reasons why the state does not
switch to 8. In general, it is a bad idea wait until a known state is
entered; it is far better to wait (or interrupt)on the SI signal (in
I2CONSET) and respond to the state that is entered.
I hope this helps,
Thiadmer