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.

Beaglebone Starterware Pinmux

Hi,

I'm using a beaglebone white for my project. I know how to change pin mux when I was using Angstrom (with device tree), but how do I change pinmux in starterware. I want to use some of the pins for GPMC.

Cheers,

Jack

  • Jack,

    One simple example in StarterWare is the gpio led blink example.  It calls GPIO1Pin23PinMuxSetup() in ~\platform\beaglebone\gpio.c.

    All that does is write to the proper pin configuration register to connect the pin to the GPMC:

    HWREG(SOC_CONTROL_REGS + CONTROL_CONF_GPMC_A(7)) = CONTROL_CONF_MUXMODE(7);

    You can do this for any pin not being used for another function.  Finding the register is the trick.  For that, go to the Data Sheet for the AM335x,

    sprs717f is the current one, I believe.

    Gerry Belanger

  • Hi Gerald,

    A second concern then, I used that method and tried to change some of the pins to the GPMC mode, but it doesn't change and still remains in made 7 rather than mode 0;

    I have a beaglebone white (I know BBB has some problems regarding this).

    Here is a sample of my code.

    #define MUX_VAL(OFFSET,VALUE)\
    *((unsigned int*)(SOC_CONTROL_REGS+OFFSET)) = VALUE

    MUX_VAL(CONTROL_PADCONF_GPMC_AD0, 0x20);

    Cheers!

    Jack

  • Jack,

    According to the Data Sheet, that pin is by default a GPIO, mode 7.  The code you show looks like it is forcing it to Mode 0, as an Address/data pin.

    If you want to force it to GPIO, with the receiver enabled, 0x27 would be the value.

    I assume your CONTROL_PADCONF_GPMC_AD0 resolves to 0x800.

    Gerry Belanger

  • Yes CONTROL_PADCONF_GPMC_AD0 resolves to 0x800.

    But I want it to be a GPMC at mode 0 and not GPIO at mode 7, but it's not being forced to a Mode 0.

  • Jack,

    I guess I got turned around as to what you want to do. 

    I agree your code should work.  I am assuming you want the pulldown enabled. and need the receiver enabled.

    I can't think of any reason it would not work.

    GerryB

  • int main(void) {
    MUX_VAL(CONTROL_PADCONF_GPMC_AD0, 0x20); /* gpmc_ad0 */
    MUX_VAL(CONTROL_PADCONF_GPMC_AD1, 0x20); /* gpmc_ad1 */
    MUX_VAL(CONTROL_PADCONF_GPMC_AD2, 0x20); /* gpmc_ad2 */
    MUX_VAL(CONTROL_PADCONF_GPMC_AD3, 0x20); /* gpmc_ad3 */
    MUX_VAL(CONTROL_PADCONF_GPMC_AD4, 0x20); /* gpmc_ad4 */
    MUX_VAL(CONTROL_PADCONF_GPMC_AD5, 0x20); /* gpmc_ad5 */
    MUX_VAL(CONTROL_PADCONF_GPMC_AD6, 0x20); /* gpmc_ad6 */
    MUX_VAL(CONTROL_PADCONF_GPMC_AD7, 0x20); /* gpmc_ad7 */
    MUX_VAL(CONTROL_PADCONF_GPMC_AD8, 0x20); /* gpmc_ad8 */
    MUX_VAL(CONTROL_PADCONF_GPMC_AD9, 0x20); /* gpmc_ad9 */
    MUX_VAL(CONTROL_PADCONF_GPMC_AD10, 0x20); /* gpmc_ad10 */
    MUX_VAL(CONTROL_PADCONF_GPMC_AD11, 0x20); /* gpmc_ad11 */
    MUX_VAL(CONTROL_PADCONF_GPMC_AD12, 0x20); /* gpmc_ad12 */
    MUX_VAL(CONTROL_PADCONF_GPMC_AD13, 0x20); /* gpmc_ad13 */
    MUX_VAL(CONTROL_PADCONF_GPMC_AD14, 0x20); /* gpmc_ad14 */
    MUX_VAL(CONTROL_PADCONF_GPMC_AD15, 0x20); /* gpmc_ad15 */
    unsigned int value[16];
    value[0] = MUX_RD(CONTROL_PADCONF_GPMC_AD0); /* gpmc_ad0 */
    value[1]=MUX_RD(CONTROL_PADCONF_GPMC_AD1); /* gpmc_ad1 */
    value[2]=MUX_RD(CONTROL_PADCONF_GPMC_AD2); /* gpmc_ad2 */
    value[3]=MUX_RD(CONTROL_PADCONF_GPMC_AD3); /* gpmc_ad3 */
    value[4]=MUX_RD(CONTROL_PADCONF_GPMC_AD4); /* gpmc_ad4 */
    value[5]=MUX_RD(CONTROL_PADCONF_GPMC_AD5); /* gpmc_ad5 */
    value[6]=MUX_RD(CONTROL_PADCONF_GPMC_AD6); /* gpmc_ad6 */
    value[7]=MUX_RD(CONTROL_PADCONF_GPMC_AD7); /* gpmc_ad7 */
    value[8]=MUX_RD(CONTROL_PADCONF_GPMC_AD8); /* gpmc_ad8 */
    value[9]=MUX_RD(CONTROL_PADCONF_GPMC_AD9); /* gpmc_ad9 */
    value[10]=MUX_RD(CONTROL_PADCONF_GPMC_AD10); /* gpmc_ad10 */
    value[11]=MUX_RD(CONTROL_PADCONF_GPMC_AD11); /* gpmc_ad11 */
    value[12]=MUX_RD(CONTROL_PADCONF_GPMC_AD12); /* gpmc_ad12 */
    value[13]=MUX_RD(CONTROL_PADCONF_GPMC_AD13); /* gpmc_ad13 */
    value[14]=MUX_RD(CONTROL_PADCONF_GPMC_AD14); /* gpmc_ad14 */
    value[15]=MUX_RD(CONTROL_PADCONF_GPMC_AD15); /* gpmc_ad15 */

    int l;
    for (l=0; l<16; l++)
    {
    printf("%x\n", value[l]);
    }

    return 0;

    }

    #define AM335X_CTRL_BASE 0x44E10000

    #define MUX_VAL(OFFSET,VALUE)\
    *((unsigned int*)(AM335X_CTRL_BASE+OFFSET)) = VALUE

    unsigned int MUX_RD(OFFSET)
    {
    return *((unsigned int*)(AM335X_CTRL_BASE+OFFSET));
    }

  • After some searching, I found that the problem had to do with user mode and privileged mode. I need to change to privileged mode in order to change the pin mux.

  • Thanks very much Jack.

    Your reply helped me a lot. I was stuck with exactly same problem from last 3 days. None of my UART were working.

    But now with help of your post and with some more research on TI forum I finally found out about CPUSwitchToPrivilegedMode() and CPUSwitchToUserMode() found in cpu.h,  which can be used to switch to privileged mode from user mode.

    I am also adding links to the post I referred, to help other user get more details:

    http://e2e.ti.com/support/arm/sitara_arm/f/791/t/207053.aspx

    http://e2e.ti.com/support/embedded/starterware/f/790/t/308692.aspx

    http://e2e.ti.com/support/development_tools/code_composer_studio/f/81/t/101958.aspx

    http://e2e.ti.com/support/microcontrollers/hercules/f/312/t/343714.aspx

    Thanks again

    UART_Init