MCUXpresso SDK Documentation

lpc_gpio_led_output

lpc_gpio_led_output#

Overview#

The GPIO Example project is a demonstration program that uses the KSDK software to manipulate the general-purpose outputs. The example use LEDs and buttons to demonstrates GPIO API for port and pin manipulation (init, set, clear, and toggle).

Supported Boards#

EVK-MIMXRT595
Hardware requirements
  • Micro USB cable

  • EVK-MIMXRT595 board

  • Personal Computer

Board settings
Prepare the Demo
  1. Connect a micro USB cable between the PC host and the CMSIS DAP USB port (J40) on the board

  2. Open a serial terminal with the following settings:

    • 115200 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  3. Download the program to the target board.

  4. Launch the debugger in your IDE to begin running the demo.

Running the demo

The log below shows the output in the terminal window:

 GPIO Driver example

 The LED is taking turns to shine.

 Standard port read: 100001

 Masked port read: 100000

 Port state: 100000
 ...

Press the SW2 will toggle the LED RED state.

EVK-MIMXRT685
Hardware requirements
  • Micro USB cable

  • EVK-MIMXRT685 board

  • Personal Computer

Board settings
Prepare the Demo
  1. Connect a micro USB cable between the PC host and the CMSIS DAP USB port (J5) on the board

  2. Open a serial terminal with the following settings:

    • 115200 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  3. Download the program to the target board.

  4. Launch the debugger in your IDE to begin running the demo.

Running the demo

The log below shows the output in the terminal window:

 GPIO Driver example

 The LED is taking turns to shine.

 Standard port read: 2018004

 Masked port read: 2010000

 Port state: 18004

 Port state: 18004
 ...

Press the SW2 will toggle the LED BLUE state.

FRDM-MCXW23
Hardware requirements
  • Type-C USB cable

  • FRDM-MCXW23 Board

  • Personal Computer

Board settings

No special settings are required.

Prepare the Demo
  1. Connect a USB cable between the host PC and the FRDM board J10.

  2. Open a serial terminal with the following settings:

    • 115200 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  3. Download the program to the target board.

  4. Either press the reset button on your board or launch the debugger in your IDE to begin running the demo.

Running the demo

The log below shows the output of the demo in the terminal window:

Example output:

 GPIO Driver example

 The LED is taking turns to shine.

 Standard port read: 1c100c

 Masked port read: 1c0000

 Port state: 18100c

 Port state: 10100c

 Port state: 18100c

 Port state: 10100c
 ...
  • When press sw2 the LED BLUE will toggle.

FRDM-RW612
Hardware requirements
  • Micro USB cable

  • FRDM-RW612 board

  • Personal Computer

Board settings

No special settings

Prepare the Demo
  1. Connect a micro USB cable between the PC host and the MCU-Link USB port (J10) on the board

  2. Open a serial terminal with the following settings:

    • 115200 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  3. Download the program to the target board.

  4. Launch the debugger in your IDE to begin running the demo.

Running the demo

The log below shows the output in the terminal window:

 GPIO Driver example

 The LED is taking turns to shine.

 Standard port read: 2000000

 Masked port read: 2000000

 Port state: 0

 Port state: 1
 ...

When press sw2 the LED BLUE will toggle.

LPC845BREAKOUT
Hardware requirements
  • Micro USB cable

  • LPC845 Breakout board

  • Personal Computer

Board settings

No special settings are required.

Prepare the demo
  1. Connect a micro USB cable between the PC host and the CMSIS DAP USB port on the board.

  2. Open a serial terminal with the following settings:

    • 9600 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  3. Download the program to the target board.

  4. Either press the reset button on your board or launch the debugger in your IDE to begin running the demo.

Running the demo

The log below shows example output of the gpio driver demo in the terminal window:

 GPIO Driver example

 The LED is taking turns to shine.

 Standard port read: 3fffff

 Masked port read: 3f0000

 Port state: fffff067

 Port state: fffff067
 ...
  • When press K3 the LD1 GREEN will turn to shine.

LPCXpresso51U68
Hardware requirements
  • Mini/micro USB cable

  • LPCXpresso51U68 board

  • Personal Computer

Board settings

This example project does not call for any special hardware configurations. Although not required, the recommendation is to leave the development board’s jumper settings and configurations in default state when running this example.

Prepare the Demo

Connect a serial cable from the debug UART port of the board to the PC. Start Tera Term (http://ttssh2.osdn.jp) and make a connection to the virtual serial port.

  1. Start Tera Term

  2. New connection -> Serial

  3. Set appropriate COMx port (x is port number) in Port context menu. Number is provided by operation system and could be different from computer to computer. Select COM number related to virtual serial port. Confirm selected port by OK button.

  4. Set following connection parameters in menu Setup->Serial port… Baud rate: 115200 Data: 8 Parity: none Stop: 1 Flow control: none

  5. Confirm selected parameters by OK button.

Running the demo

After the board is flashed the Tera Term will print message on terminal.

Example output:

 GPIO Driver example

 The LED is taking turns to shine.

 Standard port read: fffdffff

 Masked port read: fffdffff

 Port state: fffdffff

 Port state: fffdffff

 Port state: fffdffff

 Port state: fffdffff
 ...
  • When press sw1 the LED GREEN will turn to shine and you can Probe oscilloscope at J1-14 to see output signal.

Note: maybe exist different output log for different board configurations.

LPCXpresso54628
Hardware requirements
  • Micro USB cable

  • LPCXpresso54628 board

  • Personal Computer

Board settings

No special settings are required.

Prepare the Demo
  1. Connect a micro USB cable between the host PC and the LPC-Link USB port (J8) on the target board.

  2. Open a serial terminal with the following settings:

    • 115200 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  3. Download the program to the target board.

Running the demo

Either press the reset button on your board or launch the debugger in your IDE to begin running the demo.

The following lines are printed to the serial terminal when the demo program is executed.

GPIO Driver example

The LED is taking turns to shine.

Standard port read: ffbffffe

Masked port read: ffbffffe

Port state: ffbffffe

Then press the SW2, the LED3 will start to shine.

Press corresponding switches to generate events This example project does not call for any special hardware configurations. Although not required, the recommendation is to leave the development board’s jumper settings and configurations in default state when running this example.

LPCXpresso54S018
Hardware requirements
  • Micro USB cable

  • LPCXpresso54S018 board

  • Personal Computer

Board settings

No special settings are required.

Prepare the Demo
  1. Connect a micro USB cable between the host PC and the LPC-Link USB port (J8) on the target board.

  2. Open a serial terminal with the following settings:

    • 115200 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  3. Download the program to the target board.

Running the demo

This demo is an external flash plain load demo, ROM will copy image in external flash to SRAMX to run:

  1. Build the demo to generate a bin file. Note: If need to generate bin file using MCUXpresso IDE, below steps need to be followed: Set in example Properties->C/C++ Build->Settings->Build steps->Post-build steps->Edit enbable arm-none-eabi-objcopy -v -O binary “&{BuildArtifactFileName}” “&{BuildArtifactFileBaseName}.bin”

      This plainload example linked the vector table to 0x00000000, but program to external flash 0x10000000.
    
  2. Program the bin file to external on board flash via SEGGER J-FLASH Lite(V6.22 or higher):

    a. Open SEGGER J-FLASH Lite, select device LPC54S018.

    b. Click the ‘Erase Chip’ to erase the extrenal flash.(if can not success, press SW4 button and reset the board, and try to erase again)

    c. Select the bin data file, set the ‘.bin/Erase Start’ address to 0x10000000, then click ‘Program Device’ Note: Please use above way to program the binary file built by armgcc tool chain to external flash. For IAR, KEIL, MCUXpresso IDE, you can use the IDE tool to program the external flash.
    Launch the debugger in your IDE to begin running the demo.

The following lines are printed to the serial terminal when the demo program is executed.

GPIO Driver example

The LED is taking turns to shine.

Standard port read: ffbff7ff

Masked port read: bfbff7ff

Port state: bfbff7ff

Then press the SW2, the LED3 will start to shine.

Press corresponding switches to generate events This example project does not call for any special hardware configurations. Although not required, the recommendation is to leave the development board’s jumper settings and configurations in default state when running this example.

LPCXpresso54S018M
Hardware requirements
  • Micro USB cable

  • LPCXpresso54S018M board

  • Personal Computer

Board settings

No special settings are required.

Prepare the Demo
  1. Connect a micro USB cable between the host PC and the LPC-Link USB port (J8) on the target board.

  2. Open a serial terminal with the following settings:

    • 115200 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  3. Download the program to the target board.

Running the demo

This demo is an external flash plain load demo, ROM will copy image in external flash to SRAMX to run:

  1. Build the demo to generate a bin file. Note: If need to generate bin file using MCUXpresso IDE, below steps need to be followed: Set in example Properties->C/C++ Build->Settings->Build steps->Post-build steps->Edit enbable arm-none-eabi-objcopy -v -O binary “&{BuildArtifactFileName}” “&{BuildArtifactFileBaseName}.bin”

      This plainload example linked the vector table to 0x00000000, but program to external flash 0x10000000.
    
  2. Program the bin file to external on board flash via SEGGER J-FLASH Lite(V6.22 or higher):

    a. Open SEGGER J-FLASH Lite, select device LPC54S018M.

    b. Click the ‘Erase Chip’ to erase the extrenal flash.(if can not success, press SW4 button and reset the board, and try to erase again)

    c. Select the bin data file, set the ‘.bin/Erase Start’ address to 0x10000000, then click ‘Program Device’ Note: Please use above way to program the binary file built by armgcc tool chain to external flash. For IAR, KEIL, MCUXpresso IDE, you can use the IDE tool to program the external flash.
    Launch the debugger in your IDE to begin running the demo.

The following lines are printed to the serial terminal when the demo program is executed.

GPIO Driver example

The LED is taking turns to shine.

Standard port read: 7b80107c

Masked port read: 7b80107c

Port state: 7b80107c

Then press the SW2, the LED3 will start to shine.

Press corresponding switches to generate events This example project does not call for any special hardware configurations. Although not required, the recommendation is to leave the development board’s jumper settings and configurations in default state when running this example.

LPCXpresso55S06
Hardware requirements
  • Mini/micro USB cable

  • LPCXpresso55S06 board

  • Personal Computer

Board settings
Prepare the Demo
  1. Connect a micro USB cable between the PC host and the CMSIS DAP USB port (J1) on the board

  2. Open a serial terminal with the following settings (See Appendix A in Getting started guide for description how to determine serial port number):

    • 115200 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  3. Download the program to the target board.

Running the demo

After the board is flashed the Tera Term will print message on terminal.

Example output:

 GPIO Driver example

 The LED is taking turns to shine.

 Standard port read: 40290

 Masked port read: 40000

 Port state: 64001804

 Port state: 64001804

 Port state: 64001804

 Port state: 64001804
 ...
  • When press sw1 the LED GREEN will turn to shine

LPCXpresso55S16
Hardware requirements
  • Mini/micro USB cable

  • LPCXpresso55S16 board

  • Personal Computer

Board settings

The jumper setting: Default jumpers configuration does not work, you will need to add JP20 and JP21 (JP22 optional for ADC use)

Prepare the Demo
  1. Connect a micro USB cable between the PC host and the CMSIS DAP USB port (J1) on the board

  2. Open a serial terminal with the following settings (See Appendix A in Getting started guide for description how to determine serial port number):

    • 115200 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  3. Download the program to the target board.

Running the demo

After the board is flashed the Tera Term will print message on terminal.

Example output:

 GPIO Driver example

 The LED is taking turns to shine.

 Standard port read: 40290

 Masked port read: 40000

 Port state: 64001804

 Port state: 64001804

 Port state: 64001804

 Port state: 64001804
 ...
  • When press sw1 the LED GREEN will turn to shine

LPCXpresso55S28
Hardware requirements
  • Mini/micro USB cable

  • LPCXpresso55S28 board

  • Personal Computer

Board settings

This example project does not call for any special hardware configurations.

Prepare the Demo

Note: MCUXpresso IDE project default debug console is semihost

  1. Connect a micro USB cable between the PC host and the CMSIS DAP USB port (P6) on the board

  2. Open a serial terminal with the following settings (See Appendix A in Getting started guide for description how to determine serial port number):

    • 115200 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  3. Download the program to the target board.

Running the demo

After the board is flashed the Tera Term will print message on terminal.

Example output:

 GPIO Driver example

 The LED is taking turns to shine.

 Standard port read: 402c0

 Masked port read: 40000

 Port state: 64001804

 Port state: 64001804

 Port state: 64001804
 
 Port state: 64001804
 ...
  • When press s1 the LED GREEN will turn to shine

LPCXpresso55S36
Hardware requirements
  • Mini/micro USB cable

  • LPCXpresso55S36 board

  • Personal Computer

Board settings
Prepare the Demo
  1. Connect a micro USB cable between the PC host and the CMSIS DAP USB port (J1) on the board

  2. Open a serial terminal with the following settings (See Appendix A in Getting started guide for description how to determine serial port number):

    • 115200 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  3. Download the program to the target board.

Running the demo

After the board is flashed the Tera Term will print message on terminal.

Example output:

 GPIO Driver example

 The LED is taking turns to shine.

 Standard port read: 40290

 Masked port read: 40000

 Port state: 64001804

 Port state: 64001804

 Port state: 64001804

 Port state: 64001804
 ...
  • When press sw1 the LED RED will turn to shine

LPCXpresso55S69
Hardware requirements
  • Mini/micro USB cable

  • LPCXpresso55s69 board

  • Personal Computer

Board settings

This example project does not call for any special hardware configurations.

Prepare the Demo

Note: MCUXpresso IDE project default debug console is semihost

  1. Connect a micro USB cable between the PC host and the CMSIS DAP USB port (P6) on the board

  2. Open a serial terminal with the following settings (See Appendix A in Getting started guide for description how to determine serial port number):

    • 115200 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  3. Download the program to the target board.

Running the demo

After the board is flashed the Tera Term will print message on terminal.

Example output:

 GPIO Driver example

 The LED is taking turns to shine.

 Standard port read: 402c0

 Masked port read: 40000

 Port state: 64001804

 Port state: 64001804

 Port state: 64001804

 Port state: 64001804
 ...
  • When press s1 the LED GREEN will turn to shine

LPCXpresso802
Hardware requirements
  • Micro USB cable

  • LPCXpresso54018 board

  • Personal Computer

Board settings

No special settings are required.

Prepare the Demo
  1. Connect a micro USB cable between the host PC and the LPC-Link USB port (J8) on the target board.

  2. Open a serial terminal with the following settings:

    • 9600 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  3. Download the program to the target board.

Running the demo

Either press the reset button on your board or launch the debugger in your IDE to begin running the demo.

The following lines are printed to the serial terminal when the demo program is executed.

GPIO Driver example

The LED is taking turns to shine.

Standard port read: ffbff7ff

Masked port read: bfbff7ff

Port state: bfbff7ff

Then press the USER, the LD21&&LE22 will start to shine.

Press corresponding switches to generate events This example project does not call for any special hardware configurations. Although not required, the recommendation is to leave the development board’s jumper settings and configurations in default state when running this example.

LPCXpresso804
Hardware requirements
  • Mini/micro USB cable

  • LPCXpresso804 board

  • Personal Computer

Board settings

This example project does not call for any special hardware configurations. Although not required, the recommendation is to leave the development board’s jumper settings and configurations in default state when running this example.

Prepare the Demo

Connect a serial cable from the debug UART port of the board to the PC. Start Tera Term (http://ttssh2.osdn.jp) and make a connection to the virtual serial port.

  1. Start Tera Term

  2. New connection -> Serial

  3. Set appropriate COMx port (x is port number) in Port context menu. Number is provided by operation system and could be different from computer to computer. Select COM number related to virtual serial port. Confirm selected port by OK button.

  4. Set following connection parameters in menu Setup->Serial port… Baud rate: 9600 Data: 8 Parity: none Stop: 1 Flow control: none

  5. Confirm selected parameters by OK button.

Running the demo

After the board is flashed the Tera Term will print message on terminal.

Example output:

 GPIO Driver example

 The LED is taking turns to shine.

 Standard port read: 7ffffbb7

 Masked port read: 7fff0000

 Port state: 7ffffbb7

 Port state: 7ffffbb7
 ...
  • When press sw1 the LED blue will turn to shine.

LPCXpresso824MAX
Hardware requirements
  • Mini/micro USB cable

  • LPCXpresso824MAX board

  • Personal Computer

Board settings

This example project does not call for any special hardware configurations. Although not required, the recommendation is to leave the development board’s jumper settings and configurations in default state when running this example.

Prepare the Demo

Connect a serial cable from the debug UART port of the board to the PC. Start Tera Term (http://ttssh2.osdn.jp) and make a connection to the virtual serial port.

  1. Start Tera Term

  2. New connection -> Serial

  3. Set appropriate COMx port (x is port number) in Port context menu. Number is provided by operation system and could be different from computer to computer. Select COM number related to virtual serial port. Confirm selected port by OK button.

  4. Set following connection parameters in menu Setup->Serial port… Baud rate: 9600 Data: 8 Parity: none Stop: 1 Flow control: none

  5. Confirm selected parameters by OK button.

Running the demo

After the board is flashed the Tera Term will print message on terminal.

Example output:

 GPIO Driver example

 The LED is taking turns to shine.

 Standard port read: fffffff7

 Masked port read: ffff0000

 Port state: fffffff7

 Port state: fffffff7
 ...
  • When press sw1 the LED GREEN will turn to shine.

  • When press sw2 the LED RED will turn to shine.

LPCXpresso845MAX
Hardware requirements
  • Mini/micro USB cable

  • LPCXpresso845max board

  • Personal Computer

Board settings

This example project does not call for any special hardware configurations. Although not required, the recommendation is to leave the development board’s jumper settings and configurations in default state when running this example.

Prepare the Demo

Connect a serial cable from the debug UART port of the board to the PC. Start Tera Term (http://ttssh2.osdn.jp) and make a connection to the virtual serial port.

  1. Start Tera Term

  2. New connection -> Serial

  3. Set appropriate COMx port (x is port number) in Port context menu. Number is provided by operation system and could be different from computer to computer. Select COM number related to virtual serial port. Confirm selected port by OK button.

  4. Set following connection parameters in menu Setup->Serial port… Baud rate: 9600 Data: 8 Parity: none Stop: 1 Flow control: none

  5. Confirm selected parameters by OK button.

Running the demo

After the board is flashed the Tera Term will print message on terminal.

Example output:

 GPIO Driver example

 The LED is taking turns to shine.

 Standard port read: fffffff7

 Masked port read: ffff0000

 Port state: fffffff7

 Port state: fffffff7
 ...
  • When press sw2 the LED GREEN will turn to shine.

  • When press sw1 the LED RED will turn to shine.

LPCXpresso860MAX
Hardware requirements
  • Micro USB cable

  • LPCXpresso860max board

  • Personal Computer

Prepare the Demo
  1. Connect a micro USB cable between the PC host and the CMSIS DAP USB port (J4) on the board

  2. Open a serial terminal with the following settings (See Appendix A in Getting started guide for description how to determine serial port number):

    • 9600 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  3. Download the program to the target board.

  4. Either press the reset button on your board or launch the debugger in your IDE to begin running the demo.

Running the demo

Users are prompted to press the SW2, and board will blink the LED.

MIMXRT685-AUD-EVK
Hardware requirements
  • Micro USB cable

  • MIMXRT685-AUD-EVK board

  • Personal Computer

Board settings
Prepare the Demo
  1. Connect a micro USB cable between the PC host and the CMSIS DAP USB port (J5) on the board

  2. Open a serial terminal with the following settings:

    • 115200 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  3. Download the program to the target board.

  4. Launch the debugger in your IDE to begin running the demo.

Running the demo

The log below shows the output in the terminal window:

 GPIO Driver example

 The LED is taking turns to shine.

 Standard port read: 2018004

 Masked port read: 2010000

 Port state: 18004

 Port state: 18004
 ...

When press sw2 the LED BLUE will turn to shine.

RD-RW612-BGA
Hardware requirements
  • Micro USB cable

  • RD-RW612-BGA board

  • Personal Computer

Board settings

Ensure R520 is removed, R518 is installed to make SW4 work.

Prepare the Demo
  1. Connect a micro USB cable between the PC host and the MCU-Link USB port (J7) on the board

  2. Open a serial terminal with the following settings:

    • 115200 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  3. Download the program to the target board.

  4. Launch the debugger in your IDE to begin running the demo.

Running the demo

The log below shows the output in the terminal window:

 GPIO Driver example

 The LED is taking turns to shine.

 Standard port read: 2000007

 Masked port read: 2000000

 Port state: 7

 Port state: 3
 ...

When press sw4 the LED1 will toggle.

MCXW23-EVK
Hardware requirements
  • Mini/micro USB cable

  • MCXW23-EVK Board

  • Personal Computer

Board settings

No special settings are required.

Prepare the Demo
  1. Connect a USB cable between the host PC and the EVK board J33.

  2. Open a serial terminal with the following settings:

    • 115200 baud rate

    • 8 data bits

    • No parity

    • One stop bit

    • No flow control

  3. Download the program to the target board.

  4. Either press the reset button on your board or launch the debugger in your IDE to begin running the demo.

Running the demo

The log below shows the output of the demo in the terminal window:

Example output:

 GPIO Driver example

 The LED is taking turns to shine.

 Standard port read: 1c100c

 Masked port read: 1c0000

 Port state: 18100c

 Port state: 10100c

 Port state: 18100c

 Port state: 10100c
 ...
  • When press sw4 the LED BLUE will toggle.