ΣSigmaStudio Ask AI Русский Log in

BF504 - I2C - ANAK(Address Not Acknowledged) problem

Processors & DSP maxxisis Mar 5, 2011 00:00 2 replies Original on forum ↗
Subscribe
maxxisis Question
Mar 5, 2011 00:00

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

}

WassimB Reply
Mar 14, 2011 00:00

Hi,

Here are a few suggestions for things to look for:

1- Are the pins correctly configured to select the I2C signals? By default, the pins are configured as general purpose I/O.

2- Please note that the address to write into TWI_MASTER_ADDR should not include the read/write bit. This bit will be inserted automatically.

3. For your reference, there is an example I2C implementation in VisualDSP under the following directory:

<VisualDSP installation directory>\Blackfin\Examples\ADSP-BF506F EZ-KIT Lite\Power_On_Self_Test

Hope this helps.

Regards,

Wassim

maxxisis Reply
Mar 16, 2011 00:00

Hi WassimB,

thank for your reply. It was a hardware problem. I had on my PCB wrong rezistors. There should be 1k5 pull-up for I2C, but I soldered 33OHM by error. Code from Examples\ADSP-BF506F EZ-KIT Lite\Power_On_Self_Test helped me to better configure registers, thanks