Skip to main content
Bwang.3
Associate III
May 29, 2024
Solved

I would like to ask a question about button control! Hope to receive a reply!

  • May 29, 2024
  • 1 reply
  • 2182 views

I looked at the routine of SPC582B60E1! In the routine, pressing a button can use the callback function that interrupts the button to light up the LED light, but I have a question: how can I turn off the already lit LED light when I release the button? Can you give me some ideas or routines? I want to learn them! This is very important to me, thank you all big shots!

Best answer by Bwang.3

Hello! I have defined two interrupts in the external interrupt EIRQ17, namely the rising edge interrupt and the falling edge interrupt! As shown in the following picture! Is this definition acceptable? Also, can the name of this Callback only be written as cb_eirq17? If that's the case, then if I define the callback functions for the rising and falling edges as having the same name, will the program execute incorrectly due to the same callback function name during execution?

QQ图片20240530230956.pngQQ图片20240530231048.pngQQ图片20240530231145.png

1 reply

Max VIZZINI
Technical Moderator
May 30, 2024

Hi,

You need to set 2 external interrupts: 1 on raising edge and 1 on falling edge.

Best Regards,

AutoDevKit Team

Bwang.3
Bwang.3Author
Associate III
May 30, 2024

Hello! What I want to ask is can a button set both rising and falling edge interrupts simultaneously?

Max VIZZINI
Technical Moderator
May 30, 2024

Hi,

The button generates an interrupt to the MCU. 

You can set on both raising and falling edge the interrupt.

Best Regards,

AutoDevKit Team