2013-03-10 03:38 PM
Hi,
In our system, we are trying to debounce switches on GPIO lines. Every msec the switch is sampled using TIM3. After 16 ticks, if the input has settled, the idea is to set the interrupt pending register and trigger the interrupt. E.g.simple code to illustrate if (db_count = 16) EXTI->PR = 0x00000200; else EXTI_ClearITPendingBit(EXTI_Line9); Is this code valid. ie Can I manually set the interrupt pending register like this. When I use this method, I never see the pending reg being set at all. Is there anything else I need to do in order to set this reg? Many Thanks Bob2013-03-12 02:35 PM
I understand all the types etc..it is the two lines below that are confusing...
if switch state == new switches return My take on this is,,, So if current switch state is the same as new switches...do nothing as the new switches hasn't changed...is this correct? if old switches == new switches set switch state and set action flag This to me means if the last switch value is the sames as the new switch values, which implies that no switch change has been made. Would it not be ...if (old switches ^ new switches) set switch state and set action flag....This would detect a change in the switches.2013-03-13 04:51 AM
Hello;
another approch for key debouncing 1. You can buy special ''factory'' debnounced switches 2. use an RC circuit to provide the input signal to the µC Port 3. Use the ''one shot'' function of the build in µC Timers2013-03-13 07:57 AM
NO, ''same as the new switch values'' is taken care of in the previous statement, THIS means that the switches read the same twice i.e. are debounced
Erik2013-03-13 11:37 PM
another approch for key debouncing
1. You can buy special ''factory'' debnounced switches
2. use an RC circuit to provide the input signal to the µC Port
3. Use the ''one shot'' function of the build in µC Timers
4. You can buy ''switch debounce'' chips; eg,
See also:2013-03-14 01:27 AM
Hi Erik,
Thanks for that...got you now.