Correct method to drive GPIO?

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

Correct method to drive GPIO?

1,310 Views
fastwalker2
Contributor II

Hi All,

I have an LPXCpresso43S67 board which I finally have working with the LPCxpresso IDE.  I want to simply drive one of the GPIOs that goes to the Arduino headers.  Looking online I found this pic. below describing the pins.  So for example if I wanted to drive P2_13, would the code be?  I.e. what is the mapping of ports & pins to those Arduino headers?

Chip_GPIO_SetPinState(LPC_GPIO_PORT, 2, 13, true);

lpcxpresso4337_arduino1_enabled.png

Tags (1)
0 Kudos
5 Replies

993 Views
frankchiu
Contributor II

Hi Sean,

Just to make sure, have you download LPCOpen? It contains many code examples.

You said you have an LPCXpresso43S67 board, but the picture you attached is for LPCXpresso4337.

I don't know whether two boards are the same, and I assume you have the first one.

I see P2_13 is in the same position on my board.

You can find the official documents of MCU LPC43S67JET100 on the board at:

LPC43S67JET100|Arm® Cortex-M4/M0|32-bit MCU|NXP    

In the data sheet, you can find pin description.

For example, the pin P2_13 is in p. 19. It can be configured as GPIO1[13] in FUNC0.

Therefore, you may try the following code:

    Chip_SCU_PinMuxSet(0x2, 13, (SCU_MODE_INACT | SCU_MODE_FUNC0));  /* P2_13 => GPIO1[13] */
    Chip_GPIO_SetPinDIROutput(LPC_GPIO_PORT, 1, 13);
    Chip_GPIO_SetPinState(LPC_GPIO_PORT, 1, 13, (bool) true);

Hope this helps.

Frank

993 Views
simon_prentice
Contributor III

Hi Frank,

1. Where does the information "/* P2_13 => GPIO1[13] */" come from?

I can't find it in UM1053 LPC User Manual or LPC4370 Data Sheet.

2. What settings are required for Port 3 Pin 3?

Thanks,

Simon.

0 Kudos

993 Views
frankchiu
Contributor II

Hi Simon,

I am not sure if I understand your problems correctly.

I guess you are trying to make Port 3 Pin 3 on LPC4370 a GPIO pin?

According to the data sheet I found at  https://www.nxp.com/docs/en/data-sheet/LPC4370.pdf ,

p. 18 shows that P3_3 cannot be configured as a GPIO pin.

However, if you want to configure P3_4 to a GPIO pin, the above code becomes:

   Chip_SCU_PinMuxSet(0x3, 4, (SCU_MODE_INACT | SCU_MODE_FUNC0));  /* P3_4 => GP  IO1[14] */

P3_4 => GPIO1[14] comes from the first row of description of P3_4.

Got it?

Regards,

Frank

0 Kudos

993 Views
simon_prentice
Contributor III

Thanks Frank.

I was reading things completely back-to-front.

All good now (although slightly embarrassed).

0 Kudos

993 Views
frankchiu
Contributor II

Hi Simon,

Don't be embarrassed, everyone learns like this. :smileyhappy:

0 Kudos