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.

the I2C question of AM335x

Hi TI Team,

    I know the AM335x offers the standard mode (100 Kbps) and fast mode (400 Kbps)of I2C.

   when we would like to set the transmission speed rate of I2C to 100 Kbps,

   do we only modify the  I2C_SCLL and I2C_SCLH registers?

   by the way, should we set the PSC value of I2C_PSC register?

  • Hi Huang,

    Please read section 21.3.15 of the TRM:

    21.3.15 How to Program I2C

    21.3.15.1 Module Configuration Before Enabling the Module
    1. Program the prescaler to obtain an approximately 12-MHz I2C module clock (I2C_PSC = x; this value is to be calculated and is dependent on the System clock frequency).
    2. Program the I2C clock to obtain 100 Kbps or 400 Kbps (SCLL = x and SCLH = x; these values are to be calculated and are dependent on the System clock frequency).
    3. Configure its own address (I2C_OA = x) - only in case of I2C operating mode (F/S mode).
    4. Take the I2C module out of reset (I2C_CON:I2C_EN = 1).

    21.3.15.2 Initialization Procedure
    1. Configure the I2C mode register (I2C_CON) bits.
    2. Enable interrupt masks (I2C_IRQENABLE_SET), if using interrupt for transmit/receive data.
    3. Enable the DMA (I2C_BUF and I2C_DMA/RX/TX/ENABLE_SET) and program the DMA controller) - only in case of I2C operating mode (F/S mode), if using DMA for transmit/receive data.

    21.3.15.3 Configure Slave Address and DATA Counter Registers
    In master mode, configure the slave address (I2C_SA = x) and the number of byte associated with the transfer (I2C_CNT = x)

    21.3.15.4 Initiate a Transfer
    Poll the bus busy (BB) bit in the I2C status register (I2C_IRQSTATUS_RAW). If it is cleared to 0 (bus not busy), configure START/STOP (I2C_CON: STT / I2C_CON: STP condition to initiate a transfer) - only in case of I2C operating mode (F/S mode).

    21.3.15.5 Receive Data
    Poll the receive data ready interrupt flag bit (RRDY) in the I2C status register (I2C_IRQSTATUS_RAW), use the RRDY interrupt (I2C_IRQENABLE_SET.RRDY_IE set) or use the DMA RX (I2C_BUF.RDMA_EN set together with I2C_DMARXENABLE_SET) to read the received data in the data receive register (I2C_DATA). Use draining feature (I2C_IRQSTATUS_RAW.RDR enabled by I2C_IRQENABLE_SET.RDR_IE)) if the transfer length is not equal with FIFO threshold.

    21.3.15.6 Transmit Data
    Poll the transmit data ready interrupt flag bit (XRDY) in the I2C status register (I2C_IRQSTATUS_RAW), use the XRDY interrupt (I2C_IRQENABLE_SET.XRDY_IE set) or use the DMA TX (I2C_BUF.XDMA_EN set together with I2C_DMATXENABLE_SET) to write data into the data transmit register (I2C_DATA). Use draining feature (I2C_IRQSTATUS_RAW.XDR enabled by I2C_IRQENABLE_SET.XDR_IE)) if the transfer length is not equal with FIFO threshold.

    Before enabling the module you should configure the I2C_PSC register (depending on your system clock frequency) and also the I2C_SCLL and I2C_SCLH registers. Please refer to section 21.4.1 I2C Registers of the TRM for more information about the different I2C registers.

    Best regards,
    Miroslav

  • Hi, I have read the I2C section of the datasheet and I do not quiet number this part

    21.3.15.1 Module Configuration Before Enabling the Module
    1. Program the prescaler to obtain an approximately 12-MHz I2C module clock (I2C_PSC = x; this value is to be calculated and is dependent on the System clock frequency).
    2. Program the I2C clock to obtain 100 Kbps or 400 Kbps (SCLL = x and SCLH = x; these values are to be calculated and are dependent on the System clock frequency).
    3. Configure its own address (I2C_OA = x) - only in case of I2C operating mode (F/S mode).
    4. Take the I2C module out of reset (I2C_CON:I2C_EN = 1).

    My first question is where can I setup my SCLK and is there a default value?

    Once I find the SCLK and prescale it to 12-MHz using I2C_PSC, then how do I obtain 100Kbps or 400kbps using SCLL and SCLH?

    Sorry if these question seems trivial, I am still trying to learn how everything works. Thanks!

  • Hi,

    In the AM335x Starterware, there's EEPROM example, but for reading only, while I'm trying to do write.

    In reading the TRM with exactly the content in the post above, there's a statement

    only in case of I2C operating mode (F/S mode).

    What does this mean ?

    This kind of statement appears exact at 4 places, but I searched through the whole TRM PDF and found nothing about "F/S mode" !!!

    This statement does make sense to me!

    1) In I2C operating mode : Of course it must be "in I2C operating mode", what else it could be why we're trying to do I2C programming

    2) "F/S mode" : what it means ???

    Thanks,

    ~Duy-Ky

  • I found it, "F/S mode"  for "fast/standard mode" and there's NO other mode at all, so why bother to mention and make harder to use it. It's just doesn't make sense ! Probably the writer thought there're 4000+ pages in the TRM, it's not a big deal to add that statement? If it's the case, why he didn't add the full "Fast/Standard mode"!