Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

Hello guys,

I am trying to set up a basic rig to allow me to develop a reliable debounce circuit for a button I am using.
What I am trying to do is have the value 'Count' incremented every time there is a rising/falling edge and have the total displayed in binary on a bar graph display I have to hand.

The output part works fine and I am able to display whatever I like, the problem seems to be entering the ISR.
At the moment I have set the ISR to display 10101010 just to show that it has successfully been entered but the only time I have managed this is when I hold down the bootload button (Causes a crash).

I've used interrupts before in a very similar manner so I'm just confused now.

Kind regards,

Giga

0 Likes
1 Solution

Giga,

If you need it, I have a draft version of the component with random pins assignment also. All pins are assigned on startup though. To make input pins be re-assignable on-the-fly in software you have to add extra code

/odissey1

View solution in original post

0 Likes
5 Replies
Anonymous
Not applicable

I should add that I've tried to use 'CY_ISR_PROTO' before main as well.

0 Likes

You wrote

bootloadISR_StartEx(bootloadISR_Handler);
bootloadISR_StartEx(Button_Change_Handler);

But you should have

bootloadISR_StartEx(bootloadISR_Handler);
Button_Change_StartEx(Button_Change_Handler);

Additionally:

Every global variable that isaltered within an interrupt handler must be declared as "volatile".

if  ( (count & (0x01) )  == 0b00000001){Out_1_Write(1);}
else {Out_1_Write(0);}

is easier to write as

Out_1_Write(count & 0x01);

Bob

0 Likes
odissey1
Level 9
Level 9
First comment on KBA 1000 replies posted 750 replies posted

Giga,

alternatively,  you may consider using a button debouncing component ButtonSw32 (beta)

Re: Advanced button debouncing

/odissey1

0 Likes
Anonymous
Not applicable

Thanks a lot guys, I feel daft now!
Cool component odissey, especially if it handles multiple pins.
Only issue is that not all of the inputs on my port will be buttons and can change to another type of input at any given time (Modular hardware) so I'm not sure it will work for me.

0 Likes

Giga,

If you need it, I have a draft version of the component with random pins assignment also. All pins are assigned on startup though. To make input pins be re-assignable on-the-fly in software you have to add extra code

/odissey1

0 Likes