Hello all,
I've been experimenting with the Hi-Tech C compiler with a 16F876A microcontroller, and this time it's with interrupts. My code is working up to a point where I can toggle the PWM module in the PIC on and off with a single push button wired into RB5 (using interrupt on change). Additionally, the main program repeatedly flashes an LED.
The program works intermittently in so far as if the button is pressed repeatedly it will turn the PWM on and off correctly, leading me to believe that switch bounce is the reason why it isn't working smoothly. I've written previous programs to debounce switches and they have worked really well, but when I try to insert the code into the ISR the program does not function at all. Is it not possible to insert timing loops using the __delay_ms macro within ISRs? Is there an alternative method apart from using an RC circuit across the push button, and what impact would this have on the PIC if I used it?
Thanks in advance for any suggestions and advice,
Pete
I've been experimenting with the Hi-Tech C compiler with a 16F876A microcontroller, and this time it's with interrupts. My code is working up to a point where I can toggle the PWM module in the PIC on and off with a single push button wired into RB5 (using interrupt on change). Additionally, the main program repeatedly flashes an LED.
The program works intermittently in so far as if the button is pressed repeatedly it will turn the PWM on and off correctly, leading me to believe that switch bounce is the reason why it isn't working smoothly. I've written previous programs to debounce switches and they have worked really well, but when I try to insert the code into the ISR the program does not function at all. Is it not possible to insert timing loops using the __delay_ms macro within ISRs? Is there an alternative method apart from using an RC circuit across the push button, and what impact would this have on the PIC if I used it?
Thanks in advance for any suggestions and advice,
Pete