NuMaker GPIO Interrupt with Debounce Setting

Committer:
cyliang
Date:
Wed Mar 01 09:37:13 2023 +0000
Revision:
19:6e52d72cc78b
Parent:
4:a4b47a6be229
Change baud-rate as 115200, update json & os to v6.17.0 for M467 target

Who changed what in which revision?

UserRevisionLine numberNew contents of line
shliu1 4:a4b47a6be229 1 # Getting started with GPIO interrupt to flash LED on mbed OS
shliu1 4:a4b47a6be229 2
shliu1 4:a4b47a6be229 3
shliu1 4:a4b47a6be229 4 ### Import NuMaker-mbed-GPIO_Interrupt from on-line IDE
shliu1 4:a4b47a6be229 5 1. Please choose Nuvoton NuMaker-PFM-XXX as your target platform.
shliu1 4:a4b47a6be229 6 2. Please press the left-up icon "New", then choose "NuMaker GPIO interrupt to flash led1" from the template list.
shliu1 4:a4b47a6be229 7 3. Your NuMaker-mbed-GPIO_Interrupt program is existed.
shliu1 4:a4b47a6be229 8
shliu1 4:a4b47a6be229 9 #### Now compile
shliu1 4:a4b47a6be229 10 Please press compile icon.
shliu1 4:a4b47a6be229 11
shliu1 4:a4b47a6be229 12 #### Burn Code & Execute
shliu1 4:a4b47a6be229 13 1. Connect the board NuMaker-PFM-XXX with your PC by USB cable, then there will be one "mbed" disk.
shliu1 4:a4b47a6be229 14 2. Copy the built binary file into "mbed" disk on you PC.
shliu1 4:a4b47a6be229 15 3. Press device's reset button to execute, press the SW1 button to flash LED.
shliu1 4:a4b47a6be229 16
ccli8 3:2f8e3fcbdd7e 17 # Example for GPIO IRQ
ccli8 3:2f8e3fcbdd7e 18
ccli8 3:2f8e3fcbdd7e 19 This is an example for GPIO IRQ with de-bounce enabled.
ccli8 3:2f8e3fcbdd7e 20
ccli8 3:2f8e3fcbdd7e 21 ## Enable GPIO IRQ de-bounce
ccli8 3:2f8e3fcbdd7e 22
ccli8 3:2f8e3fcbdd7e 23 Add a file *mbed_app.json* with the following configuration
ccli8 3:2f8e3fcbdd7e 24
ccli8 3:2f8e3fcbdd7e 25 - gpio-irq-debounce-enable. Enable/disable GPIO IRQ de-bounce
ccli8 3:2f8e3fcbdd7e 26 - 0: disable de-bounce
ccli8 3:2f8e3fcbdd7e 27 - 1: enable de-bounce
ccli8 3:2f8e3fcbdd7e 28 - gpio-irq-debounce-clock-source. Select clock source as GPIO IRQ de-bounce is enabled.
ccli8 3:2f8e3fcbdd7e 29 - GPIO_DBCTL_DBCLKSRC_IRC10K (NuMaker-PFM-NUC472)
ccli8 3:2f8e3fcbdd7e 30 - GPIO_DBCTL_DBCLKSRC_HCLK (NuMaker-PFM-NUC472/M453)
ccli8 3:2f8e3fcbdd7e 31 - GPIO_DBCTL_DBCLKSRC_LIRC (NuMaker-PFM-M453)
ccli8 3:2f8e3fcbdd7e 32 - gpio-irq-debounce-sample-rate. Select delay as GPIO IRQ de-bounce is enabled.
ccli8 3:2f8e3fcbdd7e 33 - GPIO_DBCTL_DBCLKSEL_1
ccli8 3:2f8e3fcbdd7e 34 - GPIO_DBCTL_DBCLKSEL_2
ccli8 3:2f8e3fcbdd7e 35 - GPIO_DBCTL_DBCLKSEL_4
ccli8 3:2f8e3fcbdd7e 36 - ...
ccli8 3:2f8e3fcbdd7e 37 - GPIO_DBCTL_DBCLKSEL_32768
ccli8 3:2f8e3fcbdd7e 38
ccli8 3:2f8e3fcbdd7e 39 ### Example: enable GPIO IRQ de-bounce for NuMaker-PFM-NUC472 target
ccli8 3:2f8e3fcbdd7e 40 ```
ccli8 3:2f8e3fcbdd7e 41 {
ccli8 3:2f8e3fcbdd7e 42 "target_overrides": {
ccli8 3:2f8e3fcbdd7e 43 "NUMAKER_PFM_NUC472": {
ccli8 3:2f8e3fcbdd7e 44 "NUC472.gpio-irq-debounce-enable": 1,
ccli8 3:2f8e3fcbdd7e 45 "NUC472.gpio-irq-debounce-clock-source": "GPIO_DBCTL_DBCLKSRC_IRC10K",
ccli8 3:2f8e3fcbdd7e 46 "NUC472.gpio-irq-debounce-sample-rate": "GPIO_DBCTL_DBCLKSEL_16"
ccli8 3:2f8e3fcbdd7e 47 }
ccli8 3:2f8e3fcbdd7e 48 }
ccli8 3:2f8e3fcbdd7e 49 }
ccli8 3:2f8e3fcbdd7e 50 ```
ccli8 3:2f8e3fcbdd7e 51
ccli8 3:2f8e3fcbdd7e 52 ### Example: enable GPIO IRQ de-bounce for NuMaker-PFM-M453 target
ccli8 3:2f8e3fcbdd7e 53 ```
ccli8 3:2f8e3fcbdd7e 54 {
ccli8 3:2f8e3fcbdd7e 55 "target_overrides": {
ccli8 3:2f8e3fcbdd7e 56 "NUMAKER_PFM_M453": {
ccli8 3:2f8e3fcbdd7e 57 "M451.gpio-irq-debounce-enable": 1,
ccli8 3:2f8e3fcbdd7e 58 "M451.gpio-irq-debounce-clock-source": "GPIO_DBCTL_DBCLKSRC_LIRC",
ccli8 3:2f8e3fcbdd7e 59 "M451.gpio-irq-debounce-sample-rate": "GPIO_DBCTL_DBCLKSEL_16"
ccli8 3:2f8e3fcbdd7e 60 }
ccli8 3:2f8e3fcbdd7e 61 }
ccli8 3:2f8e3fcbdd7e 62 }
ccli8 3:2f8e3fcbdd7e 63 ```
ccli8 3:2f8e3fcbdd7e 64
ccli8 3:2f8e3fcbdd7e 65 ## Known issues
ccli8 3:2f8e3fcbdd7e 66 - GPIO IRQ de-bounce defaults to disabled. If enabled, communication with GPIO pin as interrupt pin won't fit
ccli8 3:2f8e3fcbdd7e 67 or even fail due to the de-bounce delay.