KL02 I2C communication with DAC AD5306

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

KL02 I2C communication with DAC AD5306

502 Views
albt
Contributor II

Hi everyone, I hope you can help me with this problem, I have been with this issue during several days and the problem is not solved yet.

I have the FRDM-KL02 board connected with a DAC converter (AD5306) via I2C. I have configured the I2C1 with ports A8 and A9 as SCL and SDA:

#define BOARD_I2C_GPIO_SCL          GPIO_MAKE_PIN(GPIOA_IDX, 8)

#define BOARD_I2C_GPIO_SDA          GPIO_MAKE_PIN(GPIOA_IDX, 9)

#define BOARD_I2C_INSTANCE          1

 

The KL02 acts as Master and the DAC as slave. The first communication byte has to be the slave address (7 bits) followed by the typical R/W bit. After that, another 3 bytes has to be sent.

 

I have tried to use the "I2C_DRV_MasterSendDataBlocking" but it does not work fine.

I have debugged the code and when it tries to send the addres byte via I2C (inside the function "I2C_DRV_SendAddress"), the slave address value is not transfered to the I2C1_D register specifically when next function is called:

I2C_HAL_WriteByte(I2C1_BASE_PTR, addrBuff[0]); // addrBuff[0] contains the slave address with the R/W bit = 1

 

I have checked all the I2C1 registers, and they are correct. The main sequence for the I2C communication in my project is the next one:

// Initialize i2c master

    OSA_Init();

    I2C_DRV_MasterInit(BOARD_I2C_INSTANCE, &master);     //i2c_master_state_t master;

    /**********************************************/

    // Master sends only data to slave (4 bytes: 1 Slave Addres + 1 pointer byte + 2 data bytes)

    txBuff[0]=0x01U;

    txBuff[1]=0x3FU;

    txBuff[2]=0xFFU;

    // Start transfer with buffer size is 1 byte

    I2C_DRV_MasterSendDataBlockingAD5306(BOARD_I2C_INSTANCE, &device, NULL, 0, (const uint8_t*)txBuff, sizeof(txBuff), 1000);

 

Do you have any idea of what is happening? Could you suggest me any other way to do it correctly?

 

Thanks in advance. Waiting your suggestions.

Labels (1)
Tags (3)
0 Kudos
1 Reply

310 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Andres,

After had a brief look through your statement, I haven't find any wrong with your code until now.

And I'd like to suggest that you can sample the I2C communcating wave by using the logic analyzer or the oscilloscope,

then compare the waves with the AD5306 operation sequences which are illustrated in the AD5306's datasheet.

Hope it helps.

Have a great day,

Ping

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos