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 Reply Children
  • You're right, but still don't work!

  • #include "LPC11XX.h"
    
    int main()
    {
        LPC_SYSCON->SYSAHBCLKCTRL |= (0x1UL << 16);  /* enable clock for IOCON */
        LPC_SYSCON->SYSAHBCLKCTRL |= (0x1UL << 6);   /* enable clock for GPIO  */
    
        LPC_GPIO1->DIR = 0x1;
    
        LPC_GPIO1->DATA &= ~0x1;
        LPC_GPIO1->DATA |=  0x1;
    
        while(1)
        {
            LPC_GPIO1->DATA &= ~0x1;
            LPC_GPIO1->DATA |=  0x1;
        }
    }
    

    The above code has been tested with my Keil IDE simulator, and it "worked well".
    Don't know what will happen on a real hardware, I don't have a LPC1114.

  • I would like to know what board you are using. If it is a board available to the public or is the board a in house custom board.

  • PIO1_0/AD1/CT32B1_CAP0/TMS 33
    PIO1_1/AD2/CT32B1_MAT0/TDO 34
    PIO1_2/AD3/CT32B1_MAT1/TRST/ 35
    PIO1_3/AD4/CT32B1_MAT2/SWD 39
    PIO1_4/AD5/CT32B1_MAT3/WAKEUP

    The MCB1000 schematic shows the functions of the pins.

    Does your board use a JTAG connector.. Is it possible that these pins are tied to
    Jtag. The MCB1000 does not have a jtag. but pin PIO1_3 goes to a Debug connector and
    to a header or socket.

  • PIO1_3 looks to be the SWD pin for the chip. Probably should not try to use for other purposes if you are using the debug port.

  • Your code worked fine in Keil IDE simulator, but in the hardware needed config IOCON after config DIR. If config IOCON before the DIR, don't work in the hardware. Thanks

    
    #include "LPC11XX.h"
    
    int main()
    {
        LPC_SYSCON->SYSAHBCLKCTRL |= (0x1UL << 16);  /* enable clock for IOCON */
        LPC_SYSCON->SYSAHBCLKCTRL |= (0x1UL << 6);   /* enable clock for GPIO  */
    
        LPC_GPIO1->DIR = 0x1;
    
        LPC_IOCON->R_PIO1_0 |= (0x1UL << 0);
    
        LPC_GPIO1->DATA &= ~0x1;
        LPC_GPIO1->DATA |=  0x1;
    
        while(1)
        {
            LPC_GPIO1->DATA &= ~0x1;
            LPC_GPIO1->DATA |=  0x1;
        }
    }
    
    

  • Hi, 

    I would like to use GPIO 1_20 in my lpc11uxx platform. How to define the gpio registers, direction, output high and low.. Again the same gpio will change it in input.. Like 1 wire logic can someone help me how this can be defined to operate and read the gpio. 

    Regards