Faruk Chaudhry

QG8 IIC busy flag not being cleared

Discussion created by Faruk Chaudhry on Apr 6, 2007
Latest reply on Apr 27, 2009 by Robbie Rongstad
Hi,
 
I cannot figure out why the IIC bus busy flag is not getting cleared.  The flag remains at 1 when the below code is executed a third time.
 
 
// Turns on or off a specified display LED connected to the MAX7658
void write_LEDs(unsigned char LED_number, unsigned char LED_status)
{
 
 if (LED_status == on)
   set_bit(current_Segments, LED_number);
 else
   clear_bit(current_Segments, LED_number);
 
 while(IICS_BUSY);   // wait for bus to free
 
 START_BIT;       // send start signal
 IICD = max6958_slave_address; // send calling address (write bit is included)
 while(!IICS_TCF);   // wait for byte transfer to complete
 acknowledge = check_ACK();
 if (acknowledge == DEVICE_NO_ACK )
   return;
  
 IICD = Segments;    // Segments register
 while(!IICS_TCF);   // wait for byte transfer to complete
 acknowledge = check_ACK();
 if (acknowledge == DEVICE_NO_ACK )
   return;
 
 IICD = current_Segments; // LED x on
 while(!IICS_TCF);   // wait for byte transfer to complete
 acknowledge = check_ACK();
 if (acknowledge == DEVICE_NO_ACK)
   return;
 STOP_BIT;       // send stop signal

}

Outcomes