interrupt misbehaving


Closed Thread
Results 1 to 2 of 2
  1. #1

    Default interrupt misbehaving

    Hello,

    I am trying a simple On Change interrupt on the 16f688. I am setting each pin one by one to be interrupted and move on to the next pin on each interrupt. there is only one little thing wrong with my code.

    I will begin on PORTA.0. when an OCI occures the led will blink and will change the IOCA register to PORTA.1

    next is the PORTA.1 when an OCI occures the LED will blink and will change the IOCA register to PORTA.2

    next is the PORTA.2. (HERE IS MY PROBLEM) when an OCI occures the LED will blink once and then blink again. so next should be PORTA.3 right? wrong the next OIC moves on to PORTA.4 and the code will continue fine from then on until it gets to PORTA.2 again. Here is my code and i'm hoping another pair of eyes can catch my error.

    DEFINE OSC 4
    TRISA = %111111 'PORTA as input
    TRISC = %000000 'PORTC as output
    ANSEL = 0
    CMCON0 = 7

    INTCON.7 = 1 'Global interrupt enabled
    INTCON.3 = 1 'PORTA change interupt enabled

    OPTION_REG.7 = 0 'Enable Pullup Resistors

    'Enable init interupt register
    IOCA = 1

    on interrupt GOTO myInterrupt

    LED VAR PORTC.0

    i VAR BYTE


    LOW LED
    i = 1
    main:
    HIGH PORTC.1
    LOW PORTC.1
    goto main


    disable
    myInterrupt:
    i = 2*i
    if i = 64 then i = 1
    IOCA = i 'alternate the registers
    HIGH LED
    pause 500
    LOW LED
    pause 500
    INTCON.0 = 0 'remove interrupt flag
    resume

  2. #2


    Did you find this post helpful? Yes | No

    Default

    NEVERMIND what i said. I figured out what was wrong. MCLRE does not provide a software pullup resistor and when it was that pins turn to be an IOC it would automatically toggle the LED. after putting a pullup resistor it worked fine. thanks

Similar Threads

  1. Won't go back to SLEEP after 1st Interrupt
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 32
    Last Post: - 29th June 2009, 09:00
  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. NEWBIE: Some basic questions using interrupts
    By JackPollack in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 8th March 2006, 02:59
  5. USART interrupt not interrupting right
    By Morpheus in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 6th March 2005, 01:07

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