LPC4330 GPIO out

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

LPC4330 GPIO out

Jump to solution
1,418 Views
nabeelfattah
Contributor II

Hi,

I am really straggling with programing LPC4330 with LPCXpresso IDE. I have no idea how to set gpio as an out pin?

for example; I am going to use GPIO0[14]. where is P2_10

The code I want to modified it was for LED blinky example;

#if defined (__USE_LPCOPEN)
#if defined(NO_BOARD_LIB)
#include "chip.h"
#else
#include "board.h"
#endif
#endif

#include <cr_section_macros.h>

// TODO: insert other include files here


// TODO: insert other definitions and declarations here
//#define GPIOP1 0x50020004 /* GPIO port 1 register location */


int main(void) {
#if defined (__USE_LPCOPEN)
        // Read clock settings and update SystemCoreClock variable
        SystemCoreClockUpdate();
#if !defined(NO_BOARD_LIB)
        // Set up and initialize all required blocks and

        /////////////////between this lines added by me /////////////////////
        void Chip_GPIO_Init(LPC_GPIO_T *pGPIO)
        {
        }

        STATIC INLINE void Chip_GPIO_SetPinDIROutput(LPC_GPIO_T *pGPIO, uint8_t 0, uint8_t 14) //port 0 , pin 14
        {
         pGPIO->DIR[0] |= 1UL << 14;
        }
        Chip_GPIO_SetPortOutHigh();
        Chip_GPIO_ClearValue();


        ////////////////////////////////////////////

        // functions related to the board hardware
        Board_Init();

        // Set the LED to the state of "On"
        Board_LED_Set(0, true);

#endif
#endif
         while(1) {

                Board_LED_Toggle(0);
                Delay (10000);
        }
        return 0 ;
}
 void Delay (unsigned int ms)
{
        volatile static int x,y;
        while (ms)
        {
                for (x=0; x<=140; x++)
                {
                        y++;
                }
                ms--;
        }
}

 

1 Solution
891 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Nabeel,

Thanks for your reply.

In the following codes, it illustrate how to toggle the P2_10.

    Chip_SCU_PinMuxSet(0x2, 10, (SCU_MODE_FUNC5)) // P2.10: GPIO0[14]
    Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT,0, 14); //Set pin direction
    Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, 14, false); // Output low
    Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, 14, true); // Output high
‍‍‍‍

Hope it helps.
Have a great day,
Ping

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

View solution in original post

3 Replies
891 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Nabeel Fattah,

Please refer to the blinky demo in the lpcopen_2_20_lpcxpresso_ngx_xplorer_4330, and the demo illustrates how to flashes an LED in a periodic rate.

LPCOpen Software for LPC43XX|NXP 
Have a great day,
Ping

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
891 Views
nabeelfattah
Contributor II

The attached code was from LED demo. it was not helpful.

0 Kudos
892 Views
jeremyzhou
NXP Employee
NXP Employee

Hi Nabeel,

Thanks for your reply.

In the following codes, it illustrate how to toggle the P2_10.

    Chip_SCU_PinMuxSet(0x2, 10, (SCU_MODE_FUNC5)) // P2.10: GPIO0[14]
    Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT,0, 14); //Set pin direction
    Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, 14, false); // Output low
    Chip_GPIO_SetPinState(LPC_GPIO_PORT, 0, 14, true); // Output high
‍‍‍‍

Hope it helps.
Have a great day,
Ping

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------