A quick look at your prog.
Hi,
You are turning on the LED3 in the interrupt routine and turning it off in the main loop. So technically it should work. Now consider this :
Your buttons are not debounced so it may quite happen that another rising edge is setting up your interrupt. Since you have the buttons pressed while in interrupt you are being able to detect it and light led1 and led2.
So introduce a pause inside your interrupt after turning on the LEDs and as soon as you inside the interrupt release the button. Then while getting out clear the interrupt flags. This might solve your problem.
Regards
Sougata
You are using interrupt on change
Hi,
It seems at a quick glance that you are using the interrupt on change feature on portb. This means you trigger an interrupt on every change on portb<4:7> . In plain english on every edge , a press or release of the button. So the program is jumping into the routine. Without rewiring your circuit you can disable the interrupt altogether in the interrupt routine and then clear flags and set the interrupt in the main loop.
BTW its 22:05 here and time to go home so signing off now.
Regards
Sougata
Try using the PORTB.0 interrupt
Hi,
Try using the portb.0 interrupt pin. Clear the interrupt flags (other than Global int.7) just before the resume and your circuit should work. Try using some sort of debounce circuitry as well. Good Luck. BTW your PIC has a hardware PWM. After the experiment put it to good use.
Regards
Sougata
Why have you turned on Timer0 Interrupt
Hi,
On a closer look at your prog I found that you have timer0 to use external clock via RA4. Possibily you did this because there is no timer0 enable disable bit. You wanted your timer not to work. But you have kept the input floating. Spurious counting is going on. Also you have turned on the timer0 interrupt bit in your intcon settings. So a timer0 overflow would trigger the interrupt.
So my suggestions :
1. Disable the T0IE bit
Regards
Sougata
All's well that ends well
Hi,
In helping you out I also added my experience. It really feels good when a puzzle gets solved. If you hadn't given the hints that it is jumping to the interrupt even without a button pressed I couldn't have pointed it out. So the credit goes to you for all the labour and time spent.This is only the beginning now concentrate on the PWM part and add some sparkle to your design.
I myself do not rely on the PBP interrupt and tend to use asm as my apps demand.It is not that tough if you give it a try. I am a complete self-taught without much of an academic background. My schedule doesn't permit me always to be active in this forum still I love to.
I am myself very much facinated with RGB LEDs and plan to design an ambilight as in the Phillips plasma TVs. (I cannot afford a LCD or Plasma)But everytime my hobby gets the least attention due to job pressure. I am still in my struggling phase to establish myself as a PIC programmer. I live in a city where neither PICs nor RGB LEDs are easily available. I have to get them from another metro and it is costly in terms of our economy. Still with all of you around I know I am not alone. Thanks to this forum and all PICers out there.
Have a great PICing time.
Regards
Sougata