This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

LPC1114 GPIO P1.0~P1.3 doesn't work

I'm not able to make it work the GPIO P1.0-P1.3 of LPC1114. Both in hardware as in keil debug the GPIO's P1.0 dont clear.

int main()
{
        /* Enable AHB clock to the GPIO domain. */
        LPC_SYSCON->SYSAHBCLKCTRL |= (0x1UL << 16);  /* enable clock for IOCON      */
        LPC_SYSCON->SYSAHBCLKCTRL |= (0x1UL << 6);  /* enable clock for GPIO      */

        LPC_IOCON->R_PIO1_0 |= 0x01; /* P1.0 as GPIO      */
        LPC_GPIO1->DIR  |= (1UL <<  0);                /* P1.0 as GPIO      */
        LPC_GPIO1->DATA &= ~(1UL <<  0);   /* Clear P1.0      */ //*********Don't work

        while(1);
}

what's wrong with this code?

Parents
  • Here is example code from a blinky example:

    I see a few things that are different: Maybe there is a clue in this code.

    
    #include "LPC11XX.h"
    #define KEIL_MCB1000_BOARD
    
    
    
    
    // Switch LED signal to output port with no pull up or pulldown
    void LedOutputCfg(void)
    {
      // Enable clock to IO configuration block (bit[16] of AHBCLOCK Control register)
      // and enable clock to GPIO (bit[6] of AHBCLOCK Control register
      LPC_SYSCON->SYSAHBCLKCTRL = LPC_SYSCON->SYSAHBCLKCTRL | (1<<16) | (1<<6);
    #ifdef KEIL_MCB1000_BOARD
      // For Keil MCB1000, use P2.0 for LED output
      // PIO2_0 IO output config
      //  bit[5]   - Hysteresis (0=disable, 1 =enable)
      //  bit[4:3] - MODE(0=inactive, 1 =pulldown, 2=pullup, 3=repeater)
      //  bit[2:0] - Function (0 = IO, 1=DTR, 2=SSEL1)
      LPC_IOCON->PIO2_0 = (0<<5) + (0<<3) + (0x0);
    
      // Initial bit 0 output is 0
      LPC_GPIO2->MASKED_ACCESS[1] = 0;
      // Set pin 7 to 0 as output
      LPC_GPIO2->DIR = LPC_GPIO2->DIR | 0x1;
    #else
      // For LPCXpresso, use P0.7 for LED output
      // PIO0_7 IO output config
      //  bit[5]   - Hysteresis (0=disable, 1 =enable)
      //  bit[4:3] - MODE(0=inactive, 1 =pulldown, 2=pullup, 3=repeater)
      //  bit[2:0] - Function (0 = IO, 1=CTS)
      LPC_IOCON->PIO0_7 = (0x0) + (0<<3) + (0<<5);
      // Initial bit[7] output is 0
      LPC_GPIO0->MASKED_ACCESS[1<<7] = 0;
      // Set pin 7 as output
      LPC_GPIO0->DIR = LPC_GPIO0->DIR | (1<<7);
      return;
    #endif
    } // end LedOutputCfg
    
    
    

    .

Reply
  • Here is example code from a blinky example:

    I see a few things that are different: Maybe there is a clue in this code.

    
    #include "LPC11XX.h"
    #define KEIL_MCB1000_BOARD
    
    
    
    
    // Switch LED signal to output port with no pull up or pulldown
    void LedOutputCfg(void)
    {
      // Enable clock to IO configuration block (bit[16] of AHBCLOCK Control register)
      // and enable clock to GPIO (bit[6] of AHBCLOCK Control register
      LPC_SYSCON->SYSAHBCLKCTRL = LPC_SYSCON->SYSAHBCLKCTRL | (1<<16) | (1<<6);
    #ifdef KEIL_MCB1000_BOARD
      // For Keil MCB1000, use P2.0 for LED output
      // PIO2_0 IO output config
      //  bit[5]   - Hysteresis (0=disable, 1 =enable)
      //  bit[4:3] - MODE(0=inactive, 1 =pulldown, 2=pullup, 3=repeater)
      //  bit[2:0] - Function (0 = IO, 1=DTR, 2=SSEL1)
      LPC_IOCON->PIO2_0 = (0<<5) + (0<<3) + (0x0);
    
      // Initial bit 0 output is 0
      LPC_GPIO2->MASKED_ACCESS[1] = 0;
      // Set pin 7 to 0 as output
      LPC_GPIO2->DIR = LPC_GPIO2->DIR | 0x1;
    #else
      // For LPCXpresso, use P0.7 for LED output
      // PIO0_7 IO output config
      //  bit[5]   - Hysteresis (0=disable, 1 =enable)
      //  bit[4:3] - MODE(0=inactive, 1 =pulldown, 2=pullup, 3=repeater)
      //  bit[2:0] - Function (0 = IO, 1=CTS)
      LPC_IOCON->PIO0_7 = (0x0) + (0<<3) + (0<<5);
      // Initial bit[7] output is 0
      LPC_GPIO0->MASKED_ACCESS[1<<7] = 0;
      // Set pin 7 as output
      LPC_GPIO0->DIR = LPC_GPIO0->DIR | (1<<7);
      return;
    #endif
    } // end LedOutputCfg
    
    
    

    .

Children