I am new with FREERTOS and require some assistance please.
I have a 5 button system with a 2 character LCD display. I am updating the display queue in the ISR as the button are pressed. This works great but I am getting a lot of bouncings on the switches and I am looking for away in which I can debounce the buttons in the FREERTOS.
I have decreased the size of the queue to 1 and this has helped but not 100%
Is there away in doing this?
For example what if I disable the port interrupt for 10ms and then re-enable them after the interrupt occurred?
What is the correct way of doing this in the FREERTOS?
I’d suggest to poll rather than use interrupts if those buttons are for human interaction only.
Create a thread, poll them and use a delay (wait). Debounce by looking for two consecutive readings of the same value, and adjust the delay until they are bounce free (best is to look with a 'scope to the switch lines, but you could just try some values like 20, 50mS etc).
Unless your product is very dependent on precise timing of the buttons this will probably give you the smallest code size.
I am new with FREERTOS and require some assistance please.
I have a 5 button system with a 2 character LCD display. I am updating the display queue in the ISR as the button are pressed. This works great but I am getting a lot of bouncings on the switches and I am looking for away in which I can debounce the buttons in the FREERTOS.
I have decreased the size of the queue to 1 and this has helped but not 100%
Is there away in doing this?
For example what if I disable the port interrupt for 10ms and then re-enable them after the interrupt occurred?
What is the correct way of doing this in the FREERTOS?
I’d suggest to poll rather than use interrupts if those buttons are
for human interaction only.
Create a thread, poll them and use a delay (wait). Debounce by looking
for two consecutive readings of the same value, and adjust the delay
until they are bounce free (best is to look with a 'scope to the
switch lines, but you could just try some values like 20, 50mS etc).
Unless your product is very dependent on precise timing of the buttons
this will probably give you the smallest code size.
Even though this isn’t a general programming list, I’ll give a freebie
#define mask (0b111) // make this any length you want for your debounce
uint i;
inside tick interrupt add:
i <<= 1;
if(Button_Down) {
i |= 1;
if(!(~i & mask)) {
set semaphore
}
}
–
Jerry Durand, Durand Interstellar, Inc. www.interstellar.com
tel: +1 408 356-3886, USA toll free: 1 866 356-3886
Skype: jerrydurand