I2C Speed on CY8CKIT-059

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

cross mob
DaMc_1553781
Level 1
Level 1
First like given

Hi all! 

   

I have a CY8CKIT-059 , it's great, done lots of little things so far. Tonight I decided i'd try and write some values to a 12-bit DAC.

   

I looked at a few example projects etc and can not seem to get another to come out that makes sense above about 800Hz, it's all blocky and modulated.

   

I'm pretty sure the sample rate and the conversion rate are more than adequate. Any thing i'm missing? I might also be doing the bit shifting wrong,,,,

   

Code looks like this. 

   

#include <project.h>
#define SLAVE_ADDRESS   0x62
#define WR_BUFFER_SIZE  (2u)

   

int main()
{
    uint8  sample_segment[WR_BUFFER_SIZE];
    uint16 sample_full;

   

    Opamp_1_Start();
    I2C_1_Start();
    ADC_1_Start();

   

    CyGlobalIntEnable;

   

    for(;;)
    {
        ADC_1_StartConvert();
        /* Wait until the ADC conversion is complete */
        ADC_1_IsEndConversion(ADC_1_WAIT_FOR_RESULT);
        /* Since the ADC conversion is complete, stop the conversion */
        ADC_1_StopConvert();
        sample_full = ADC_1_GetResult16();

   

        sample_segment[0] = sample_full >> 8u & 0x00FFu;
        sample_segment[1] = sample_full & 0x00FFu;

   


        I2C_1_MasterWriteBuf(SLAVE_ADDRESS, (uint8 *)sample_segment,WR_BUFFER_SIZE, I2C_1_MODE_COMPLETE_XFER);
     }
}

0 Likes
4 Replies