On Interrupt question


Closed Thread
Results 1 to 16 of 16

Hybrid View

  1. #1
    Join Date
    Feb 2005
    Posts
    130


    Did you find this post helpful? Yes | No

    Default

    I changed as you suggested but corrected the ports, I guess this is what you meant

    Code:
    but1    var PORTB.4
    but2    var PORTB.5
    ledwork var PORTA.0
    led1    var PORTA.1
    led2    var PORTA.2
    led3    var PORTA.3
    rs      var PORTA.5
    And before the loop starts I added:

    porta=0
    portb=0


    Now I can see the led1/led2 trigger after pressing for about a second, but the generic interrupt led3 is ON all the time which indicates me that the interrupt is being triggered constantly, regardless of the button presses.

    Any idea?


    Thanks


    Pablo

  2. #2
    Join Date
    Feb 2005
    Posts
    130


    Did you find this post helpful? Yes | No

    Default

    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

  3. #3
    Join Date
    Feb 2005
    Location
    Kolkata-India
    Posts
    563


    Did you find this post helpful? Yes | No

    Default 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

  4. #4
    Join Date
    Feb 2005
    Posts
    130


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by sougata
    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,

    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

  5. #5
    Join Date
    Feb 2005
    Location
    Kolkata-India
    Posts
    563


    Did you find this post helpful? Yes | No

    Default 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

  6. #6
    Join Date
    Feb 2005
    Posts
    130


    Did you find this post helpful? Yes | No

    Default

    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.

  7. #7
    Join Date
    Feb 2005
    Location
    Kolkata-India
    Posts
    563


    Did you find this post helpful? Yes | No

    Default 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

Similar Threads

  1. Interrupt question
    By ultiblade in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 26th November 2009, 20:12
  2. Can't ID interrupt source with this IntHandler??
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 3rd June 2009, 02:35
  3. Help with Analog Interrupt
    By brid0030 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 13th February 2008, 18:14
  4. USART interrupt not interrupting right
    By Morpheus in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 6th March 2005, 01:07
  5. Interrupt question
    By stone in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 25th January 2005, 23:11

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts