Post Go back to editing

TWI/I2C 21489 C code example

Hi,

I'm trying to develop a link between the ADSP 21489 and ADT7411. I have to use the I2C protocol. Could someone point me to a C code example demonstrating an I2C transaction for the ADSP 21489.


Thanks!

Parents
  • Hi Deco,

             To answer your questions:

    1. The TWI hardware takes care of sending the slave address once the register is programmed. The user need not have to send the address everytime. The code I have shared sends N bytes as programmed.

    2. If you want to use the Repeated Start condition then you can set this bit.

    I had gone through the code you have sent. I am not clear on what exactly you are trying to do. I can see that the master is enabled multiple times as below:

    *pTWIMCTL = TWIMEN | (1<<6);

        *pTWIMADDR = device_address;
       
        *pTWIMCTL = TWIMEN | (1<<6) | TWIRSTART;
        while(*pTWIFIFOSTAT & TWITXS) {};
       
        // enable rx transfer
        *pTWIMCTL = TWIMEN | (1<<6) | TWIMDIR;
      

    Can you enable the master only once for more no of data and check what happens to the TWITXS status? Also check for the error conditions in the current code which might explain on why the data is not transferred.

    I would also recommend you to use the interrupt mode of operation.

    Best Regards,

    Jeyanthi

Reply
  • Hi Deco,

             To answer your questions:

    1. The TWI hardware takes care of sending the slave address once the register is programmed. The user need not have to send the address everytime. The code I have shared sends N bytes as programmed.

    2. If you want to use the Repeated Start condition then you can set this bit.

    I had gone through the code you have sent. I am not clear on what exactly you are trying to do. I can see that the master is enabled multiple times as below:

    *pTWIMCTL = TWIMEN | (1<<6);

        *pTWIMADDR = device_address;
       
        *pTWIMCTL = TWIMEN | (1<<6) | TWIRSTART;
        while(*pTWIFIFOSTAT & TWITXS) {};
       
        // enable rx transfer
        *pTWIMCTL = TWIMEN | (1<<6) | TWIMDIR;
      

    Can you enable the master only once for more no of data and check what happens to the TWITXS status? Also check for the error conditions in the current code which might explain on why the data is not transferred.

    I would also recommend you to use the interrupt mode of operation.

    Best Regards,

    Jeyanthi

Children
No Data