NXP Semiconductors logo
LPCXpresso Logo

Reply
 
Thread Tools
  #1  
Old 05-04-2012, 09:35 PM
gastro54 gastro54 is offline
Junior Member
 
Join Date: Jul 2011
Location: North Carolina
Posts: 6
gastro54 is on a distinguished road
Default Unable to control GPIO pin

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:
Code:
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:
Code:
// 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:
Code:
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.

Last edited by gastro54; 05-04-2012 at 09:44 PM.
Reply With Quote
  #2  
Old 05-04-2012, 10:57 PM
Zero Zero is offline
Senior Member
 
Join Date: Dec 2009
Location: far away
Posts: 2,625
Zero is on a distinguished road
Default

Quote:
Originally Posted by gastro54 View Post
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?
Reply With Quote
  #3  
Old 05-05-2012, 12:00 AM
gastro54 gastro54 is offline
Junior Member
 
Join Date: Jul 2011
Location: North Carolina
Posts: 6
gastro54 is on a distinguished road
Default

Quote:
Originally Posted by Zero View Post
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...
Reply With Quote
  #4  
Old 05-05-2012, 12:06 AM
Zero Zero is offline
Senior Member
 
Join Date: Dec 2009
Location: far away
Posts: 2,625
Zero is on a distinguished road
Default

Next tip:

#1 Debug you code

or

#2 Post a complete project and hope someone debugs it
Reply With Quote
  #5  
Old 05-11-2012, 12:37 AM
gastro54 gastro54 is offline
Junior Member
 
Join Date: Jul 2011
Location: North Carolina
Posts: 6
gastro54 is on a distinguished road
Default

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.
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



All times are GMT +2. The time now is 02:06 PM.