[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

XMC4500

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 8
Thread images: 2

File: iu-1.jpg (928KB, 2928x1532px) Image search: [Google]
iu-1.jpg
928KB, 2928x1532px
Hello,
I am trying to debounce a button via software but I am some how stuck. Would appreciat if someone could give me a pointer to a solution.
Microcontroller board:
Xmc4500-1024, infineon
Relax kit, arm cortex m4
>>
File: IMG_20161001_212640.jpg (3MB, 3663x3120px) Image search: [Google]
IMG_20161001_212640.jpg
3MB, 3663x3120px
>>
>>1063845
what I do to debounce buttons is I use two separate functions in the main loop.
one disables all button-input upon pressing and sets an indicator variable, and the other re-enables all button-input and the indicator variable if the desired time delay has passed

the rest of the code is set inside a if--then statement, that checks if button-input is true
>>
Draw a state diagram to help you visualize what's going on.
>>
>>1063845
> debouncing in software
What is this homework or something?
Do people really do this?
>>
>>1063960
yes, why have extra components when you don't have to
>>
>>1063927
This is a link to a debounce arduino sketch I posted a while ago for somebody else here.
http://pastebin.com/bm8BjyT4

One aspect of this is that since the button-reset-timer function is separate from everything else in the main loop, the rest of the program continues to run while it is waiting to accept more button input.
Many of the crappy ways just put a delay() call in there, and the arduino can't do anything else while it's waiting for the button-press time to expire.

>>1063960
> debouncing in software
>What is this homework or something?
>Do people really do this?
It ends up being easier & cheaper than using a debounce chip, plus you can link different button-press delay/repeat times to different buttons or other program states
>>
>>1063845
pointer? you want a pointer?

just sample the level every 5ms (you have the GPIO setup for input on the pin and a timer correct?)

and if it's pressed 5 or more times in a row then declare it debounce pressed

if it loses it it's unpressed

draw a state diagram because your job depends on it
Thread posts: 8
Thread images: 2


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.