Unable to control GPIO pin

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Unable to control GPIO pin

1,126 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by gastro54 on Fri May 04 12:35:06 MST 2012
Hi,

EDIT: I just tried changing the pin to PIO3.0 and PIO1.11 and those are not working either, so my theory below on MAT3 being the cause is wrong.

I am unable to control the PIO0.7 pin on my LPC1114 when MAT3 is enabled (PIO0.11)

PIO0.7 is supposed to toggle low in response to a button press.  The other program functions in the button press subroutine respond to the button press, so I know the code to toggle PIO0.7 low is being executed.

The button press subroutine is:
else if (bit_is_clear(debouncedState, SWITCH_STOP_PIN))
        {
            while(debounceButtonIsPressed());
            
            // send the stop signal for 0.5s, then return the stop signal to the default level
            timer32B0SendStop(); 
            
            LED_FREQ_DATA = ~LED_FREQ_ALL; // flash leds
            
            STOP_OUTPUT_DATA &= ~(1<<STOP_OUTPUT_PIN); // bring trig line low
            
            systickDelay(50); // delay 0.5s 
            
            // revert to normal state
            timer32B0SendGo();
            STOP_OUTPUT_DATA |= (1<<STOP_OUTPUT_PIN); // return trig line high
            gpioChangeFreqLed(clockIndex); // restore previous led indication
            
        } 


Where the macros are defined as:
// STOP line is PIO0.7
#define STOP_OUTPUT_DATA GPIO_GPIO0DATA
#define STOP_OUTPUT_DIR GPIO_GPIO0DIR
#define STOP_OUTPUT_PIN 7

in gpio.h.  I am using the microbuilder.eu LPC111x.h header file from K. Townsend.

My program sets up a 100Hz - 500Hz pulse train on MAT3 (PIO0.11).

During debugging, when I watch GPIO0DATA, the only activity I see is on bit 11 (MAT3) and bit 10 (SWCLK).

PIO0.7 remains constant, at the initial state I set it to in gpioInit(), the first function I call from main(). 

gpioInit() does the following:
void gpioInit(void)
{
    SCB_SYSAHBCLKCTRL |= SCB_SYSAHBCLKCTRL_GPIO; // enable clock to the GPIO block

    // set all GPIO to input by default
    GPIO_GPIO0DIR &= ~GPIO_IO_ALL;
    GPIO_GPIO1DIR &= ~GPIO_IO_ALL;
    GPIO_GPIO2DIR &= ~GPIO_IO_ALL;
    GPIO_GPIO3DIR &= ~GPIO_IO_ALL;

    LED_FREQ_DIR |= LED_FREQ_ALL; // set all frequency leds to outputs

    STOP_OUTPUT_DIR |= (1 << STOP_OUTPUT_PIN); // set stop output pin to output
    STOP_OUTPUT_DATA |= (1 << STOP_OUTPUT_PIN); // output low on STOP
}


I have a feeling the MAT3 activity is messing up my control of GPIO0DATA, since PIO0.7 doesn't toggle when the code is downloaded to the LPC1114 and it is NOT running in debug mode.
0 Kudos
Reply
4 Replies

1,093 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by gastro54 on Thu May 10 15:37:06 MST 2012
omg.  I haven't been editing the main.c that I though I was.  I discovered this after I coded some erroneous shit and the build didn't throw any errors.  WOW.
0 Kudos
Reply

1,093 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Fri May 04 15:06:17 MST 2012
Next tip:

#1 Debug you code :)

or

#2 Post a complete project and hope someone debugs it :)
0 Kudos
Reply

1,093 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by gastro54 on Fri May 04 15:00:28 MST 2012

Quote: Zero
Your debugger (Peripheral View) is able to:

#1 Show your actual GPIO setting :)

#2 Show your actual IOCON setting :)

#3 Switch GPIO bits :)

Did you try this already?



Hey, thanks for the tip, but everything looks normal T_T

GPIO0DIR = 0x80 (only bit 7 set)
IOCON_PIO0_7 = 0xc0 (only bits 6,7, which are reserved are set)

When I toggle bit 7 in GPIO0DATA in the debugger, I see it toggle on the scope.

Something is wrong with the code execution I think...
0 Kudos
Reply

1,093 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Fri May 04 13:57:10 MST 2012

Quote: gastro54
I am unable to control the PIO0.7 pin...



Your debugger (Peripheral View) is able to:

#1 Show your actual GPIO setting :)

#2 Show your actual IOCON setting :)

#3 Switch GPIO bits :)

Did you try this already?
0 Kudos
Reply