AnsweredAssumed Answered

BF504 - I2C - ANAK(Address Not Acknowledged) problem

Question asked by maxxisis on Mar 5, 2011
Latest reply on Mar 16, 2011 by maxxisis

Hi, I have BF504 and I need to communicate over I2C. So  I wrote functions below, but I always get status ANAK in TWI_MASTER_STAT register and communication never begin. Is there anyone who would know what is wrong?? I am using JTAG so I know that address is written correctly to TWI_MASTER_ADDR...

 

void I2C_Init(){
  unsigned int Prescale = (unsigned int)(F_SCLK/10000000);
  *pTWI_CONTROL = TWI_ENA | Prescale;
  *pTWI_CLKDIV = 10000000/I2C_CLK;

}

 

void I2C_Write_Byte(unsigned char Byte_To_Send){

 

  *pTWI_MASTER_ADDR = 0x02;
  *pTWI_XMT_DATA8 = Byte_To_Send;
 
  unsigned short Bytes_Transfer_Count = 1;
  Bytes_Transfer_Count = Bytes_Transfer_Count << 6;
  *pTWI_MASTER_CTL = 0x0000;
  *pTWI_MASTER_CTL = Bytes_Transfer_Count | MEN ;          <= after this instruction I get an ANAK

}

Outcomes