AM62x MCU+ SDK  10.01.00
GPIO Input Interrupt

Introduction

This example configures a GPIO pin in input mode and configures it to generate interrupt on rising edge. The application waits for 5 key presses, prints the number of times the keys are pressed and exits.

SK-AM62 or SK-AM62-LP-SK-EVM does not contain any push button connected to MCU GPIOs. M4F example using MCU_GPIO0_15 pin in the MCU_HEADER(J9) for generating GPIO interrupt. Key presses can be done by connecting followed by disconnecting MCU_GPIO0_15(Pin 10 of J9) to ground (Pin 27 of J9) in the SK-AM62 or SK-AM62-LP.

A53 example is using GPIO0_14 pin in the User Expansion Connector(J3) for generating GPIO interrupt. Key presses can be done by connecting followed by disconnecting GPIO0_14(Pin 22 of J3) to ground (Pin 6 of J3) in the am62x-sk, am62x-sip-sk, am62x-sk-lp.

Please note that number of key presses will be higher than actual as we are manualy connecting the ground using jumpers.

Attention
A GPIO bank interrupt can be routed to only one core at a time. For example if a gpio interrupt is routed to Linux A53 core, the same cannot be routed to other cores (M4/R5).
Before running the GPIO Input interrupt example on a processor with Linux cores, disable any overlapping entries in the Linux devicetree board file. The GPIO can be excluded from the linux device tree by modifying the device tree board file (arch/arm64/boot/dts/ti/k3-am625-sk.dts)
&mcu_gpio0 {
status = "reserved";
};
&mcu_gpio_intr {
status = "reserved";
};
A new linux devicetree blob (dtb) should be generated with this change and placed in the Linux filesystem in the boot folder. For more information, reference the AM62x Linux SDK docs, section Foundational Components > Kernel > Users Guide. The kernel and kernel modules do not need to be rebuilt and reinstalled.

A new linux image to be generated with this change and SoC initialization to done following SOC Initialization Using SPL . Without this change in the linux image, this example will not work.

Attention
A GPIO bank interrupt can be routed to only one core at a time. For example if a gpio interrupt is routed to A53_0 core, the same cannot be routed to other cores (A53_1/A53_2/A53_3/R5F). In the case of AMP, currenly all cores are using the same SPI_MAIN_GPIOMUX_INTROUTER and GPIO mux introuter output number. User can change this and can be used different gpiomux interrupt router for each a53 core by making following changes in the board_gpio.c.xdt file
% if(args.project.cpu == "a53ss0-1"){
#define BOARD_BUTTON_GPIO_INTR_NUM (CSLR_GICSS0_COMMON_0_SPI_MAIN_GPIOMUX_INTROUTER0_OUTP_1)
#define BOARD_BUTTON_GPIO_SWITCH_NUM ("GPIO0_14")
%}
% else if(args.project.cpu == "a53ss0-1"){
#define GPIOMUX_INTROUTER_OUTP (1U)
%}
In this way different SPI_MAIN_GPIOMUX_INTROUTER and GPIO mux introuter output number can be assigned to other a53 cores

Supported Combinations

Parameter Value
CPU + OS m4fss0-0 nortos
a53ss0-0 freertos
a53ss0-1 freertos
a53ss1-0 freertos
a53ss1-1 freertos
Toolchain ti-arm-clang
arm.gnu.aarch64-none
Board am62x-sk, am62x-sip-sk, am62x-sk-lp
Example folder examples/drivers/gpio/gpio_input_interrupt/

Steps to Run the Example

See Also

GPIO

Sample Output

Shown below is a sample output when the application is run,

GPIO Input Interrupt Test Started ...
GPIO Interrupt Configured for Rising Edge ...
Press pushbutton SW5 to trigger a GPIO interrupt
Key is pressed 0 times
Key is pressed 0 times
Key is pressed 0 times
Key is pressed 1 times
Key is pressed 2 times
Key is pressed 3 times
Key is pressed 3 times
Key is pressed 4 times
Key is pressed 5 times
GPIO Input Interrupt Test Passed!!
All tests have passed!!
Attention
Output from the a53ss0-0, a53ss0-1, a53ss1-0 and a53ss1-1 cores are printed to UART0(/dev/ttyUSB0), UART1(/dev/ttyUSB1) WAKEUP_UART(/dev/ttyUSB2) and MCU_UART(/dev/ttyUSB3)respectively

Shown below is a sample output from a53ss1-0 when the application is run, similar logs can be seen from other a53 cores in their respective uart console

GPIO Input Interrupt Test Started ...
GPIO Interrupt Configured for Rising Edge ...
Connect the GPIO0_14 pin on EVM to ground and release to trigger GPIO interrupt ...
Key is pressed 0 times
Key is pressed 0 times
Key is pressed 0 times
Key is pressed 0 times
Key is pressed 0 times
Key is pressed 25 times
GPIO Input Interrupt Test Passed on a53_core2 !!
All tests have passed on a53_core2 !!