Jump to content
agaelema

Issues with I2C without interrupt

Recommended Posts

Hi, 

I posted a question on e2e but I found interesting to ask here too.

I'm trying to port the Adafruit MCP4725 library to MSP430 using the Driverlib. I'm testing with launchpad EXP43FR2433 running at 1MHz and I would not want to use interruption to keep the code more portable.

The sequence to write some value on DAC is relatively simple.
- Set address -> send start -> send write cmd -> send upper byte -> send lower byte -> send stop.

Using the following code one byte of the value is lost.

    msp43x_I2C_setSlaveAddress(EUSCI_B0_BASE, _i2caddr);
    msp43x_I2C_masterSendStart(EUSCI_B0_BASE);
    msp43x_I2C_masterMultiByteNext(EUSCI_B0_BASE, controlBits);         // write cmd
    msp43x_I2C_masterMultiByteNext(EUSCI_B0_BASE, dataBits / 16);         // Upper data bits (D11.D10.D9.D8.D7.D6.D5.D4)
    msp43x_I2C_masterMultiByteNext(EUSCI_B0_BASE, (dataBits % 16) << 4);  // Lower data bits (D3.D2.D1.D0.x.x.x.x)
    msp43x_I2C_masterMultiByteStop(EUSCI_B0_BASE);

i2c-01.thumb.png.ea82db4bd895129b94b67ef98d3c2c8a.png

 

But if I insert some dummy code (__delay_cycles) the transmission starts to work.

#define I2C_Delay   5
    msp43x_I2C_setSlaveAddress(EUSCI_B0_BASE, _i2caddr);
    __delay_cycles(I2C_Delay);
    msp43x_I2C_masterSendStart(EUSCI_B0_BASE);
    __delay_cycles(I2C_Delay);
    msp43x_I2C_masterMultiByteNext(EUSCI_B0_BASE, controlBits);         // write cmd
    __delay_cycles(I2C_Delay);
    msp43x_I2C_masterMultiByteNext(EUSCI_B0_BASE, dataBits / 16);         // Upper data bits (D11.D10.D9.D8.D7.D6.D5.D4)
    __delay_cycles(I2C_Delay);
    msp43x_I2C_masterMultiByteNext(EUSCI_B0_BASE, (dataBits % 16) << 4);  // Lower data bits (D3.D2.D1.D0.x.x.x.x)
    __delay_cycles(I2C_Delay);
    msp43x_I2C_masterMultiByteStop(EUSCI_B0_BASE);
    __delay_cycles(I2C_Delay);

i2c-02.thumb.png.df65bb14f98f1e491d0b836b3301998c.png

 

Someone knows what's happening?

It looks like the library is not checking if the transmission was correctly performed.

Thanks

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...