Data transmit to external D/AC using I2C

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

Nice to meet you. Thank you for seeing.

   

Please teach me how to transmit data to external 16 bit A/DC (AD5696, Analog Devices) by using I2C master in PSoC 5LP. I programmed C firmware refer to Sample Code "DelSig_I2CM" in PSoC creator, not only A/DC didn't work , but also SDA and SCL signal have been seen using oscilloscope. I think C firmware is highly likely to be wrong, but I couldn't understand reason.

   

------------------------------------------------------------------------

   

/* Parameters used:
*  I2C Master
*   Implementation      Fixed function
*   Data rate           400kbps
*   SDA SCL pin config  Open drain, drives low
*   Pull-up resistors   1.8kΩ each
*
*  Delta Sigma ADC
*    Resolution            12 bits
*    Conversion Rate       1000000 SPS
*    Input mode            Single ended
*/

   

#include <project.h>
#define I2C_SLAVE_ADDRESS    (12u)
#define WR_BUFFER_SIZE       (2u)

   

uint8   X_IN = 0u;
uint8   temp = 0u;
uint8   sample_segment[WR_BUFFER_SIZE];
uint16  result[3] = {0u};

   

int main(void)
{
    ADC_SAR_IN_Start();
    ADC_SAR_IN_StartConvert();
    I2CM_Start();
    CyGlobalIntEnable;
    
    for(;;)
    {   
        ADC_SAR_IN_IsEndConversion(ADC_SAR_IN_WAIT_FOR_RESULT);
        result[X_IN] = ADC_SAR_IN_GetResult16();
        sample_segment[0] = result[X_IN] >> 8u & 0x00FFu;
        sample_segment[1] = result[X_IN] & 0x00FFu;
        do
        {
            temp = I2CM_MasterWriteBuf(I2C_SLAVE_ADDRESS, (uint8 *)sample_segment, WR_BUFFER_SIZE, I2CM_MODE_COMPLETE_XFER);
        }
        while(temp != I2CM_MSTR_NO_ERROR);
        while(I2CM_MasterStatus() & I2CM_MSTAT_XFER_INP);
        temp = I2CM_MasterClearStatus();
    }
}

0 Likes
4 Replies