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.

I2C1 on BeagleBone Black / AM335x

Hello to all:

I'm confused with the MUX/configuration issues of setting up the expansion headers so that "bare-metal" code can access cape data.

Can someone give me a steps necessary for being able to read data from pins I2C1_SCL and I2C1_SDA ??

Thanks!

Dean

  • Hi Dean,
    First of all you should be aware that the BB Black I2C1 has no pullup resistors on the SCL and SDA lines. You will need to add these yourself in order for this interface to function.
  • Biser:

    Thanks for bringing up that point ~ although I think I'm ok at this point as I'm using a ready-made cape and simply want to access some raw data from it.

    Sincerely,
    Dean

  • I suggest you download the AM335X Starterware package and use it as a reference for your code. It's an OS-less platform and has drivers for almost all the peripherals.
  • Biser:

    Thanks for your suggestion. I have the AM335X Starterware code and searched for references to both I2C1_SDA and I2C1_SCL for inputs over pins 18 and 17 without any success.

    Can you point me to what files would help me?

    Sincerely,

    Dean

  • Sorry, I cannot help with software. There is a dedicated Starterware forum: http://e2e.ti.com/support/embedded/starterware/f/790.aspx
  • Hi Dean.  I am hacking i2c1 on the beaglebone now.  

    Did you have any success reading with it?  

    ...................dd

  • Don:

    Yes, I did. What I did was start with the "AM335X_StarterWare\examples\evmskAM335x\accelerometer\i2cAccelerometer.c" example code and modify it to use the I2C channel and slave-address I needed. I use it to communicate directly with LCD touch-screen hardware in a no-OS project.

    Dean
  • Great, thanks.  Did it work without extensive modification? 

    btw, sounds like a cool project.  Did you post it? 

    later...............dd

  • I did abit of modifications but it's a good example to start from and start getting some results.

    If I remember correctly, the Startware I2C read/write code has some "while" loops that potentially can loop-forever if something unexpected happens (hardware doesn't properly initialize, hardware-failure, etc) . It's always best to implement a time-out catch inside the "while" loops to exit with an error rather than continue to read/write indefinitely.

    Good luck with your code!

    Dean
  • Hi again Dean. I am working on modding the i2caccelerometer example.
    I cannot find the i2c1 pad DEFINES for
    CONTROL_CONF_I2C1_SDA or CONTROL_CONF_I2C1_SCL.
    They are not in hw_control_AM335x.h ( where they should be).
    Where did you get them?

    thanks................don
  • Don:

    If you are looking into "pin-muxing" what I finally used was the following code:

    // I2C0

    HWREG(SOC_CONTROL_REGS + CONTROL_CONF_I2C0_SDA) =
    (CONTROL_CONF_I2C0_SDA_CONF_I2C0_SDA_RXACTIVE |
    CONTROL_CONF_I2C0_SDA_CONF_I2C0_SDA_SLEWCTRL |
    CONTROL_CONF_I2C0_SDA_CONF_I2C0_SDA_PUTYPESEL );

    HWREG(SOC_CONTROL_REGS + CONTROL_CONF_I2C0_SCL) =
    (CONTROL_CONF_I2C0_SCL_CONF_I2C0_SCL_RXACTIVE |
    CONTROL_CONF_I2C0_SCL_CONF_I2C0_SCL_SLEWCTRL |
    CONTROL_CONF_I2C0_SCL_CONF_I2C0_SCL_PUTYPESEL );

    // I2C1

    /* I2C_SCLK */
    HWREG(SOC_CONTROL_REGS + CONTROL_CONF_SPI0_D1) =
    (CONTROL_CONF_SPI0_D1_CONF_SPI0_D1_PUTYPESEL |
    CONTROL_CONF_SPI0_D1_CONF_SPI0_D1_RXACTIVE |
    CONTROL_CONF_SPI0_D1_CONF_SPI0_D1_SLEWCTRL |
    CONTROL_CONF_MUXMODE(2));
    /* I2C_SDA */
    HWREG(SOC_CONTROL_REGS + CONTROL_CONF_SPI0_CS0) =
    (CONTROL_CONF_SPI0_CS0_CONF_SPI0_CS0_PUTYPESEL |
    CONTROL_CONF_SPI0_CS0_CONF_SPI0_CS0_RXACTIVE |
    CONTROL_CONF_SPI0_D1_CONF_SPI0_D1_SLEWCTRL |
    CONTROL_CONF_MUXMODE(2));

    //I2C2

    HWREG(SOC_CONTROL_REGS + CONTROL_CONF_UART_RTSN(1)) =
    (CONTROL_CONF_SPI0_D1_CONF_SPI0_D1_PUTYPESEL |
    CONTROL_CONF_SPI0_D1_CONF_SPI0_D1_RXACTIVE |
    CONTROL_CONF_SPI0_D1_CONF_SPI0_D1_SLEWCTRL |
    CONTROL_CONF_MUXMODE(3));
    /* I2C_SDA */
    HWREG(SOC_CONTROL_REGS + CONTROL_CONF_UART_CTSN(1)) =
    (CONTROL_CONF_SPI0_CS0_CONF_SPI0_CS0_PUTYPESEL |
    CONTROL_CONF_SPI0_CS0_CONF_SPI0_CS0_RXACTIVE |
    CONTROL_CONF_SPI0_D1_CONF_SPI0_D1_SLEWCTRL |
    CONTROL_CONF_MUXMODE(3));

    The defines are in soc_AM335x.h

    Dean