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.

Starterware/STARTERWARE-SITARA: problem with gpio output pins and pin mux

Part Number: STARTERWARE-SITARA

Tool/software: Starterware

Hey everyone,

i am facing some difficulties trying to control the gpio pins...

// 
#define GPIOP8_04       (GPIO_1_7)      //pin:P8_04,mode7:gpio1[7]
#define PINGP1          (7)
#define GPIOP8_07       (GPIO_2_7)      //pin:P8_07,mode7:gpio2[7]
#define PINGP1_2        (7)
#define GPIOP8_22       (GPIO_2_22)     //pin:P8_26,mode7:gpio2[22]
#define PINGP2          (22)
// the following code is to toggle the pins defined above
// 
    L3L4_driver_init();
    L3L4_clock_domain_open();
    GPIO1ModuleClkConfig();
    GPIO2ModuleClkConfig();
    GpioModuleEnable(SOC_GPIO_1_REGS);
    GpioModuleEnable(SOC_GPIO_2_REGS);
//pin mux setup
    // P804
    GpioPinMuxSetup(GPIOP8_04, 7);
    GPIODirModeSet(SOC_GPIO_1_REGS,PINGP1,GPIO_DIR_OUTPUT);
    // P807
    GpioPinMuxSetup(GPIOP8_07, 7);
    GPIODirModeSet(SOC_GPIO_2_REGS,PINGP1_2,GPIO_DIR_OUTPUT);
    // P822
    GpioPinMuxSetup(GPIOP8_22, 7);
    GPIODirModeSet(SOC_GPIO_2_REGS,PINGP2,GPIO_DIR_OUTPUT);
    //
    while(1)
    {
      GPIOPinWrite(SOC_GPIO_1_REGS, GPIOP8_04, GPIO_PIN_HIGH);
      Delay(0xAFFFF);
      GPIOPinWrite(SOC_GPIO_1_REGS, GPIOP8_04, GPIO_PIN_LOW);
      Delay(0xAFFFF);
      //
      GPIOPinWrite(SOC_GPIO_2_REGS, PINGP1_2, GPIO_PIN_HIGH);
      Delay(0xAFFFF);
      GPIOPinWrite(SOC_GPIO_2_REGS, PINGP1_2, GPIO_PIN_LOW);
      Delay(0xAFFFF);
      //
      GPIOPinWrite(SOC_GPIO_2_REGS, GPIOP8_22, GPIO_PIN_HIGH);
      Delay(0xAFFFF);
      GPIOPinWrite(SOC_GPIO_2_REGS, GPIOP8_22, GPIO_PIN_LOW);
      Delay(0xAFFFF);
      //
    }

The problem with this code is that the leds i connect to my beaglebone white do NOT turn on and off...instead there seems to be only a very dim light in only one of the leds (the second one, P8_07), which is also constantly on...Now the resistor i use is 470 Ohm and i am pretty sure that is not too much, as if i connect the led with pin 4 in P9 header (3.3V output) instead of the gpio pin, the led turns on just fine..
Could someone help me out? Is the pin mux not done properly? What else shoud i try?

Thanks in advance

  • Hey again,

    a kind of update...i have noticed that the moment i connect the beaglebone via usb to my host pc and BEFORE i load the program i posted in my previous post the led in P8_07 produces a very dim light..
    Also i think that mainly my problem focuses on gpio pins that are NOT in GPIO1 instance..
    Please, any suggestions?

    Thanks again
  • Hey,

    i am getting quite crazy with this issue...i even used a sd card, with an image of ubuntu in order to turn on (the bloody led) via linux and putting aside (for the moment at least) starterware and bare metal...
    The results are freaking me out...the dim light is still on, while after using cat direction under /sys/class/gpio/gpio71,  i get as a result in...
    Of course i changed it to output and echoed a 1 in value, but nothing changed...

    I remind you that i am talking about pin7 in header P8, which is gpio2[7]....

    Really, what is going on?any ideas?

    Thanks

  • Well,

    i have noticed that in my initial post, i have WRONGLY provided the GPIOPinWrite and GPIOPinMuxSetup functions with the gpio pin's physical address instead of the pin number's..

    Despite correcting that, unfortunately, i still have the same issues...

    I even tried turning on only one led (P8_27, which is gpio2[22]) and what i came across during step by step debugging is that the code CANNOT successfully surpass the GpioPinMuxSetup function..instead it drives me to the following piece of code, in exceptionHandler.S:

    AbortHandler:
    UndefInstHandler:
    ;
    ; Disable all the interrupts
    ;
            MRS     r0, cpsr                  ; Read from CPSR
            ORR     r0, r0, #0xC0             ; Clear the IRQ and FIQ bits    
            MSR     cpsr_c, r0                ; Write to CPSR
            ADD     r14, pc, #0               ; Store the return address
            LDR     pc, _CPUAbortHandler      ; Go to C handler
    ;
    ; Go to infinite loop if returned from C handler
    ;
    loop0:
            B       loop0  

    where as it is normal it just hangs there in an infinite loop...

    Please, i would appreciate any help, as i also want to apply pin muxing for pwm pins and it seems like i am facing the same problems...

    Thanks again

  • Hey everyone,

    i am terribly sorry but i have messed everything up..i have completely messed up with the gpio names and the pin numbers....Also GpioPinMuxSetup function actually needs as it's first parameter, the gpio name and not address as i claimed wrongly in my previous post...

    Anyway, paying some more attention in the differences between gpio name, pin number and physical address certainly rewards as now everything works smoothly...

    Sorry for the trouble