DT_instantINT 16f690 not working... what am I doing wrong?


Results 1 to 5 of 5

Threaded View

  1. #2
    Join Date
    Mar 2009
    Posts
    653


    Did you find this post helpful? Yes | No

    Default Re: DT_instantINT 16f690 not working... what am I doing wrong?

    IOCB.7=1 is correct (you are enabling that pin for interupt on change interrupts)

    You will also need to enable Weak pullups...
    OPTION_REG.7 = 0
    WPUB.7 = 1 '

    I normally use a variable mapped to the associated interrupt bit like this...

    IOC_FLAG VAR INTCON.0 ' Alias RABIF interrupt flag bit

    ...then it's easier to track clearing it, for example...

    IOC_FLAG = 0 ' Clear the int-on-change flag bit

    (the flag needs to be cleared before you enable with @ INT_ENABLE RABC_INT )

    also it's a good idea to put a wend in at the beginning of your program to ensure things have settled. So pulling the sequence together would look something like this

    Code:
    ASM
    INT_LIST  macro ; IntSource,    Label,         Type, ResetFlag?
        INT_Handler  RABC_INT,  _Switch_Interrupt,  PBP,  YES
        end
    
        INT_CREATE       ; Creates the interrupt processor
    ENDASM
    '
    IOC_FLAG = 0          ' Clear the int-on-change flag bit
      '
    WHILE SW1 = 0 : WEND  ' Wait until all sw has settled and is at logic 1 before proceeding
    '
    @ INT_ENABLE RABC_INT   ; Now things have settled,eEnable 'Int On Change' interrupts

    If it's still not working, get a DVM onto RB7 and make sure it's sitting at supply voltage. RB7 is also the EUSART TX pin, so if you're using anything with serial output, that could cause you grief, from recollection, it can be disabled something like this...

    RCSTA.7 = 0


    It sounds like your LED1 is actually toggling fine...it's just that it's toggling at one helluva lick (hence dim)....better to put a pause in your interrupt routine to give it a breather between on & off...

    Code:
    '---[INT - interrupt handler]---------------------------------------------------
    ToggleLED1:
         TOGGLE LED0
    pause 250
    @ INT_RETURN
    Hope that helps a little.
    Last edited by HankMcSpank; - 6th November 2011 at 01:39.

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