Im still puzzled by this, I know I must be near, but Im missing the finish line by a byte or two
Thanks, help is appreciated
Im still puzzled by this, I know I must be near, but Im missing the finish line by a byte or two
Thanks, help is appreciated
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
Hi Sougata,Originally Posted by sougata
If I enter any pause in the interrupt routine (I just tried it) I severelly impair the PWM loops, and this is another indication that the interrupt is being triggered constantly.
Here is the schematic:
Thanks
Pablo
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
The interrupt is triggered as soon the pic starts, without even pressing a single time any button.
I set the OPTION_REG as follows
bit7 = 1 PORTB pull-ups are disabled
bit6 = 1 Interrupt on rising edge of RB0/INT pin
bit5 = 0 Internal instruction cycle clock (CLKOUT)
bit4 = 1 Increment on high-to-low transition on RA4/T0CKI pin
bit3 = 0 Prescaler is assigned to the Timer0 module
bit2 = 0 Prescaler Rate Select bits
bit1 = 0
bit0 = 1 TMR0 Rate 1:4 WDT Rate 1:2
I can rewire the schematic at will, so if you have a solution this way, please let me know.
Thanks!
Last edited by peu; - 27th January 2006 at 17:45.
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
Hi again Sougata,
I need 3 PWM thats why I use the soft version. And regarding the interrupts I need 2 buttons, thats why I choosed the port change instead of the single PortB.0 method.
Any idea on how to do that?
Thanks again!
Bookmarks