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.

uEnv enable MUX on Beaglebone Black

Is there a way to configure PIN / Mux in the uEnv.txt boot file?

What I want to accomplish is setting up I2C1_SDA (Pin 18) and I2C1_SCL (Pin 17) for input when the BeagleBone Black boots (note, I'm running bare-bones so no OS).

My current uEnv.txt is very simple:

uenvcmd=mmc rescan;fatload mmc 0:1 0x80300000 main.bin;go 0x80300000

Thanks!

Dean

  • Hi Dean,

    You are at least booting to U-Boot since you are using the uEnv file and also U-Boot commands. I guess you can modify the control module registers directly using the "mw" U-Boot command in your uEnv.txt file, but this doesn't seem like a fast and easy approach.

    Since you are already using U-Boot, why don't you do the pinmuxing you desire inside the <u-boot_dir>/board/ti/evm/evm.h file:

    #define MUX_EVM() \
    ...

    You can also do it in your bare bone application.

    Best regards,
    Miroslav

  • Miroslav:

    Thanks for your input on my question. I like your suggestion of just handling the pinmuxing configuration inside my bare-bones code. That leads me to more questions that I hope you can help me with. I really don't understand what the steps are to setting muxing:

    1) I Need Pin-18 to be set to Mode#2 so that I can read the I2C1_SDA signal over it. How do I configure that? I've looked in the Tech-Manual at the I2C Register fields but didn't see anything for setting the "Mode".

    2) Once the "Mode" is correctly set is the pin ready to "Read"? Or do I have to set the Read/Write mode somehow? I don't need to "Write" at all, I only want to "Read" this pin.

    3) And finally, how do I "read" pin #18? The manual lists the I2C registers starting at 0x4802_A000 and there is an offset for I2C_DATA of 0x9C . However, I don't understand how I'm to get the data for "Pin #18" or "I2C1_SDA" so I'm confused. . .

    Sincerely and Thank you!

    Dean

  • Dean,

    The "mode" of the pin is selected through the corresponding CONTROL_MODULE register. Please read this chapter of the TRM and take a look at 9.3.1.51 conf_<module>_<pin> Register (offset = 800h–A34h).

    I don't know if you are aware of the StarterWare package, but it is very suitable for bare-bone applications. You can download it from here: http://processors.wiki.ti.com/index.php/StarterWare

    There is an I2C example, which I suggest you check out. The example name is "i2cAccelerometer". It will guide you through the process of pinmuxing the I2C pins, setuping the I2C interface and reading/writing.

    Here is a code snippet of the SetupI2C function:

     /*
     ** Configures i2c bus frequency and slave address.
     ** It also enable the clock for i2c module and
     ** does pinmuxing for the i2c.
     */
    static void SetupI2C(void)
    {
        I2C1ModuleClkConfig();
    
        I2CPinMuxSetup(1);
    
        /* Put i2c in reset/disabled state */
        I2CMasterDisable(SOC_I2C_1_REGS);
    
        /* Auto Idle functionality is dsabled */
        I2CAutoIdleDisable(SOC_I2C_1_REGS);
    
        /* Configure i2c bus speed to 100khz */
        I2CMasterInitExpClk(SOC_I2C_1_REGS, I2C_SYSTEM_CLOCK, I2C_INTERNAL_CLOCK,
                            I2C_OUTPUT_CLOCK);
    
        /* Set i2c slave address */
        I2CMasterSlaveAddrSet(SOC_I2C_1_REGS, I2C_SLAVE_ADDR);
    
        /* Bring I2C module out of reset */
        I2CMasterEnable(SOC_I2C_1_REGS);
    }

    Best regards,
    Miroslav

  • Miroslav:

    Thanks for that clue! I'm trying to work with that "Accelerometer" demo code as a guide. But I'm having some trouble:

    First off, I'm not using interrupts because I have a time-critical process and only wish to poll the I2C1_SDA for data when it doesn't interfere with anything else. So after initialization of the I2C1 (no errors so I guess it setup correctly), I'm simply calling function "I2CMasterDataGet(SOC_I2C_1_REGS);" in the demo code when I want data. However, it always returns me a value of 0x87 everytime. I'm next calling the function "I2CMasterStop(SOC_I2C_1_REGS);" after my data read as I assumed it was to clear the buffer but it's not working.

    Any ideas for me?

    Dean

  • Dean, to me it seems like you configure everything correctly. Can you look at the clock and data lines using an oscilloscope or a logic analyser? This is of great use when debugging serial interfaces.

    Please note that there is also a StarterWare dedicated forum, so maybe you can ask any questions about the StarterWare part of your code there: http://e2e.ti.com/support/embedded/starterware/f/790.aspx

    Best regards,
    Miroslav

  • Miroslav:

    Thanks again for your help.

    Here is a bigger "picture" of what I'm needing to do: I'm trying to connect with a touch-screen/LCD with "bare-bones" code (link to cape http://www.chipsee.com/product/evm/beagle/beaglebone-black-expansion-capacitive.html ). Now, I know that the cape's touch-interface is over the GPIO1 (bit 17), I2C1_SDA and I2C1_SCL pins based on their supplied schematic:

    Now, I am able to "read" the GPIO1 bit #17 and it shows my "touch-events" (boolean flag). So now I'm trying to read the "SDA" for the serial data. The Chipsee people have supplied me with their Linux code but it contains 37,842 files and I haven't been able to figure out where or what they are doing. And their support people really do not have any code knowledge at all. . .

    I am fairly ignorant on this serial interfacing so this question is very elementary: Why is "I2C1_SCL" part of this interface? Isn't it a "Clock" signal? Why do I care about it??

    Dean

  • The I2C1_SCL line is the clock for the I2C interface. It's just how I2C works. Please read more about the I2C and how it functions.

    The BeagleBone capes are generally supported at the BeagleBone community forums so you may also take a look there: http://beagleboard.org/Community/Forums

    Best regards,
    Miroslav

  • Is there a way to "read" the pin/muxing settings? I just want to verify that the mode is getting set correctly with my I2C experimenting.

    Thanks!

    Dean

  • Miroslav:

    I still might have something not setup correctly. I "read" the I2C_IRQSTATUS_RAW flags (after trying to read) and it reports: 10000110

    Field #7 is AERR which suggests that the I2C_DATA/RX-FIFO was empty when I tried to read it.

    Dean

  • I have a strange problem.

    When measuring the I2C bus with an oscilloscope, everything seems to be working perfectly. Only one problem, the I2C_IRQSTATUS_RAW flags readout 10000111 (0x87) wich means: AL , NAK, ARDY and AERR are being set. 

    When I transmit or receive, doesn't matter, these flags are always being set. This is nonsense because the data transmits to my slave succesfully (I can see it with my scope !! ) and when I read the slave it sends the correct data back (on the scope).  Although, no data is being read in my software (my array just isn't updated, its ignored) and I get these error flags wich make no sense because the thing is working! Especially the AL bit makes me furious, because I have only one master and I can see on my scope the bus is free when I press a key to initiate the transfer, witch then successfully appears on the oscilloscope.  


  • I even read correct data in my software now (very stupid mistake) but the error flags keep saying there are errors, although all communications seem to work correctly (as measured, and the data read back in from the slave ...)