Are you trying to use Flag
as the ack? The logic doesn't make sense. Don't you need to do something like
while (Flag == false)
; //wait for flag to become true after previous write
...write...
Flag = false;
mtrw
2010-02-18 08:23:29