This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMS320F28335 I2C to programming SIGMA ADAU1701

Other Parts Discussed in Thread: TMS320F28335

Hello.

I try to create a code to TMS320F28335 that make a boot using I2C.

But When I try to write by I2C the dsp show a kind of protocol diferrent than when I program the sigma DSP By PC.

To start It i create a program that write a Addres + data at TMS320F28335 I2C without plug the SCL and SDA in a slave.

when I did It, I tryed to see at osciloscope what happen and I just can see The addres!

Do you know if I dont have the ACK what happen?

Do you Know if I can't send a data if I dont have da addres ACK?

The image show me write at I2C adress + data but you can se just the addres repeating!

Thanks

 

 

 

  • Raul,

    The I2C protocol requires an ACK from the slave on all bytes, including the address byte. You need to hook the slave up.

    Regards,
    Dave Foley

     

  • Hello...

    Now I get the ACK, but I have other problem!

    I use this funcion to sent a addres and data!

    ___________________________________________________________________________________________________
    Uint16 SIGMA_WRITE_REGISTER_BLOCK(int devAddress, int address, int data_Length, const void*  dados)
    {
    ADI_REG_TYPE *pointer = (ADI_REG_TYPE *)dados;
    ADI_REG_TYPE address_MSB = 0x00;
    ADI_REG_TYPE address_LSB = 0x00;

    // Wait until the STP bit is cleared from any previous master communication.
    // Clearing of this bit by the module is delayed until after the SCD bit is
    // set. If this bit is not checked prior to initiating a new message, the
    // I2C could get confused.
    if (I2caRegs.I2CMDR.bit.STP == 1)
    {
    return I2C_STP_NOT_READY_ERROR;
    }

    // Check if bus busy
    if (I2caRegs.I2CSTR.bit.BB == 1)
    {
    return I2C_BUS_BUSY_ERROR;
    }

    address_LSB = ((ADI_REG_TYPE) (address & 0xFF));
    address = (address>>8);
    address_MSB = ((ADI_REG_TYPE) (address & 0xFF));

    // Setup number of bytes to send
    // MsgBuffer + Address
    I2caRegs.I2CCNT = data_Length+3;

    I2caRegs.I2CDXR = devAddress;
    I2caRegs.I2CDXR = address_MSB;
    I2caRegs.I2CDXR = address_LSB;

    for (i=0; i<data_Length; i++)
    {
        I2caRegs.I2CDXR = *pointer++;
    }

    // Send start as master transmitter
    I2caRegs.I2CMDR.all = 0x6E28;


    return I2C_SUCCESS;
    }

    ___________________________________________________________________________________________________

    The problem that I have is when I sent more than 16 bytes I can see in oscilloscope that send the first byte = 0 and I don't get the ACK.

    But If I send a messange whith 16 bytes or less its work fine!

    Maybe I need to copy all to SDA and after do the stop condition?

    Maybe I have this interrupt At my code that don't permit me to send mor than 16 bytes because I find this code in a EPROM example end Try to chose some thing for my aplication.

    Plz some one know to explain to me what this interrupt do?

    ___________________________________________________________________________________________________
    interrupt void i2c_int1a_isr(void)     // I2C-A
    {
       Uint16 IntSource, i;
       // Read interrupt source
       IntSource = I2caRegs.I2CISRC.all;
       // Interrupt source = stop condition detected
       if(IntSource == I2C_SCD_ISRC)
       {
          // If completed message was writing data, reset msg to inactive state
          if (CurrentMsgPtr->MsgStatus == I2C_MSGSTAT_WRITE_BUSY)
          {
             CurrentMsgPtr->MsgStatus = I2C_MSGSTAT_INACTIVE;
          }
          else
          {
             // If a message receives a NACK during the address setup portion of the
             // EEPROM read, the code further below included in the register access ready
             // interrupt source code will generate a stop condition. After the stop
             // condition is received (here), set the message status to try again.
             // User may want to limit the number of retries before generating an error.
             if(CurrentMsgPtr->MsgStatus == I2C_MSGSTAT_SEND_NOSTOP_BUSY)
             {
                CurrentMsgPtr->MsgStatus = I2C_MSGSTAT_SEND_NOSTOP;
             }
             // If completed message was reading EEPROM data, reset msg to inactive state
             // and read data from FIFO.
             else if (CurrentMsgPtr->MsgStatus == I2C_MSGSTAT_READ_BUSY)
             {
                CurrentMsgPtr->MsgStatus = I2C_MSGSTAT_INACTIVE;
                for(i=0; i < I2C_NUMBYTES; i++)
                {
                  CurrentMsgPtr->MsgBuffer[i] = I2caRegs.I2CDRR;
                }
             {
             // Check recieved data
             for(i=0; i < I2C_NUMBYTES; i++)
             {
                if(I2cMsgIn1.MsgBuffer[i] == I2cMsgOut1.MsgBuffer[i])
                {
                    PassCount++;
                }
                else
                {
                    FailCount++;
                }
             }
             if(PassCount == I2C_NUMBYTES)
             {
                pass();
             }
             else
             {
                fail();
             }

          }
        }
          }
       }  // end of stop condition detected
       // Interrupt source = Register Access Ready
       // This interrupt is used to determine when the EEPROM address setup portion of the
       // read data communication is complete. Since no stop bit is commanded, this flag
       // tells us when the message has been sent instead of the SCD flag. If a NACK is
       // received, clear the NACK bit and command a stop. Otherwise, move on to the read
       // data portion of the communication.
       else if(IntSource == I2C_ARDY_ISRC)
       {
          if(I2caRegs.I2CSTR.bit.NACK == 1)
          {
             I2caRegs.I2CMDR.bit.STP = 1;
             I2caRegs.I2CSTR.all = I2C_CLR_NACK_BIT;
          }
          else if(CurrentMsgPtr->MsgStatus == I2C_MSGSTAT_SEND_NOSTOP_BUSY)
          {
             CurrentMsgPtr->MsgStatus = I2C_MSGSTAT_RESTART;
          }
       }  // end of register access ready
       else
       {
          // Generate some error due to invalid interrupt source
          asm("   ESTOP0");
       }
       // Enable future I2C (PIE Group 8) interrupts
       PieCtrlRegs.PIEACK.all = PIEACK_GROUP8;
    }
    void pass()
    {
        asm("   ESTOP0");
        for(;;);
    }
    void fail()
    {
        asm("   ESTOP0");
        for(;;);
    }
    ___________________________________________________________________________________________________

    Plz, How I send more than 16 bytes by I2C?

    Thanks.