on interrupt help


Closed Thread
Results 1 to 8 of 8
  1. #1
    Join Date
    Apr 2008
    Posts
    43

    Smile on interrupt help

    can somebody tell me why my code keeps resetting please
    Code:
     Define LCD_DREG PORTB
     'Set starting data bit
     Define LCD_DBIT 4 'rb4,rb5,rb6,rb7
     'Set LCD RS Port
     DEFINE LCD_RSREG portb
     'Set LCD RS Bit
     define LCD_RSBIT 3
     'Set LCD Enable Port
     Define LCD_EREG portb
     'Set LCD Enable Bit
     Define LCD_EBIT 2
     'Set number of LCD Lines
     Define LCD_LINES 2
     'Set Command Delay time in uS
     define LCD_COMMANUS 2000
     'Set Data delay time in uS
     define LCD_DATAUS 50
    
    pause 100   'let lcd start
    
    symbol fire = portb.1
    symbol ac = portb.0
    symbol up = porta.0
    symbol down = porta.1
    maxdelay var word
    maxdelay = 8000
    delay var word
    delay = 0
    trisa = %00000011
    trisb = %00000001
    
    
    lcdout 254,1, "BenjiTEMP"
    lcdout 254,192, "Dimmer v1"
    pause 1000
    lcdout 254,1
    
    on interrupt goto firetriac
    intcon = %10010000
    
     
    
    scan:
    
    if up = 1 then 
    delay = delay + 2
    if delay > maxdelay then
    delay = maxdelay 
    endif
    endif
    
    if down = 1 then 
    delay = delay - 2
    if delay < 2 then
    delay = 2 
    endif
    endif
     
    goto scan
    
    firetriac:
    pauseus maxdelay - delay
    fire = 1
    pauseus 10
    fire = 0 
    INTCON.1=0
    resume
    enable

  2. #2
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,648


    Did you find this post helpful? Yes | No

    Lightbulb

    Hi,

    DISABLE before the interrupt stubb could be the first good idea ...

    a look at OPTION_REG.6 could be a good idea too ( value depends on your zero crossing method ...)


    by the way , processor ?= 16F84a ???

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  3. #3
    Join Date
    Apr 2008
    Posts
    43


    Did you find this post helpful? Yes | No

    Default

    yep a 16f84. thanks for your help, i got portb.1 through a resister strait to a rectifier so I guess OPTION_REG.6 = 0 for a negative edge??

  4. #4
    Join Date
    Apr 2008
    Posts
    43


    Did you find this post helpful? Yes | No

    Default

    found the problem, it was the watchdog but now i can get the interupt to trigger properly.
    it seems like once the interrupt is triggered it just keeps triggering? even if I strap it to ground while running? strange

    Code:
    on interrupt goto firetriac
    intcon = %10010000
    scan:
    fire = 0
    if up = 1 then 
    delay = delay + 100
    if delay > maxdelay then
    delay = maxdelay 
    endif
    lcdout 254,1, dec delay
    endif
    
    if down = 1 then 
    delay = delay - 100
    if delay < 100 then
    delay = 100 
    endif
    lcdout 254,1, dec delay
    endif
     
    goto scan
    
    
    disable
    firetriac:
    pauseus maxdelay - delay
    fire = 1
    pauseus 10
    fire = 0
    intcon.0 = 0
    resume
    enable

  5. #5
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Must be INTCON.1=0
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  6. #6
    Join Date
    Apr 2008
    Posts
    43


    Did you find this post helpful? Yes | No

    Default

    you are "THE MAN"
    cheers

  7. #7
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    well... your first code was right but i noticed the INTCON change between your 2 version, then i looked into the datasheet to confirm it could be the problem.. seems yes.

    Out of curiosity, which version of the compiler are you using? The Watch-Dog reset sounds weird to me as the compiler should handle it for you... unless you ask to not doing it with a DEFINE.

    I could also bet on a hardware problem... but i don't see any schematic... bah... since it's working now
    Last edited by mister_e; - 25th April 2008 at 15:46.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  8. #8
    Join Date
    Apr 2008
    Posts
    43


    Did you find this post helpful? Yes | No

    Default

    2.46 it doesnt seem to do it anymore but when it did i unchecked the wdt box on ic prog

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