I2C API problem

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

I am working with a Pioneer board and a CYBLE-012011 eval board. I've instantiated an I2C interface that I've connected to an external MCP4725 DAC, powered by the Pioneer board. I trigger writes to the DAC using a counter with an interrupt on terminal count. My interrupt service routine just sets a flag that my main program checks.

   


When I attempt to write three bytes to the DAC using the non-blocking, interrupt driven API function SCB_I2CMasterWriteBuf, the output of the I2C has the first byte (the address) correct, but the three bytes of data are all 0's. If, however, I put in a delay after the SCB_I2CMasterWriteBuf function call (either a printf or a CyDelay(1u)), it works correctly. I am able to watch the I2C bus on an oscilloscope. However, this severely limits the bandwidth of I2C writes I can perform - I'm limited by the 1 millisecond delay.

   


I then changed my code to use the separate functions SCB_I2CMasterSendStart, SCB_I2CMasterWriteByte, and SCB_I2CMasterSendStop. These also work, and I can do I2C bus transactions at approximately 12 KHz, but since they're blocking, I'm unable to do anything else while my data is being written out on the I2C, which won't work for the project I'm designing.

   


Do you know why the SCB_I2CMasterWriteBuf API function behaves in this fashion and is there a way to do faster, non-blocking I2C transactions? I'm attaching my project bundle.

   

On a side note, I've only gotten the UART and I2C to work by leveraging off a 100days project (HRM_datalogger). If I start from scratch, copying my code into the new project, neither the UART or the I2C work.

   

Thanks.

   


 

0 Likes
10 Replies