interrupt newbie


Closed Thread
Results 1 to 9 of 9

Hybrid View

  1. #1


    Did you find this post helpful? Yes | No

    Default

    How are you incrementing the timevariable? From what I can tell the timevariable will always be 0.

  2. #2
    trebdms's Avatar
    trebdms Guest


    Did you find this post helpful? Yes | No

    Default hello again

    thanks dave for the quick response. i just tried the code you posted, i still get the same results. my apologies...i must have been i bit vague on what i have posted. anyway, im still aiming for the same results... heres my code:


    im using 12f675 by the way. One more thing, in setting up an interrupt on
    GPIO.2, do i have to put a pull-up resistor on the pin?

    ------------------------------------------------------------------------
    define OSC 20 'OSC (20Mhz)

    INTCON=%00010000 'Enable Interrupt
    OPTION_REG.6=0 'Trigger on Falling edge
    CMCON = 7 'Disables Analog Inputs
    ANSEL = 0 'Sets Analog Inputs as Digital I/O

    on interrupt goto init
    pause 500


    VARS:

    LED1 VAR GPIO.0 'LED Port
    Rx VAR GPIO.3 'Receive Data Port
    CS VAR GPIO.2 'Interuppt Port
    BUFF2 var byte[17] 'Rx Recive read buff
    SPEED con 188 'Sio data speed 4800bps

    Cnt var BYTE 'Recive data count
    RD1 VAR byte 'Read Data Counter
    CN var BYTE 'Counter

    X var word
    cmd var word
    CNT = 0
    CN = 0

    eeprom ["1111111111111111"]

    INCLUDE "MODEDEFS.BAS"

    TRISIO = %101010

    '-----------------------------------------------------------------
    ' RX Data from remote
    '-----------------------------------------------------------------

    MAIN:

    serin2 rx,SPEED,5,SUB,[wait("#"),str buff2\18\"@"]
    IF BUFF2[0]=">" THEN

    for cn = 0 to 16
    read cn,rd1
    if rd1 = buff2[cn] then
    CNT=CNT+1
    ENDIF
    next cn

    IF CNT = 16 THEN

    IF BUFF2[16] = "1" THEN
    cmd = 1

    'trigger interrupt here
    LOW CS
    PAUSE 200
    HIGH CS

    endif

    IF BUFF2[16] = "2" THEN
    cmd = 2

    'trigger interrupt here
    LOW CS
    PAUSE 200
    HIGH CS

    endif

    gosub GetCmd

    ENDIF

    endif

    SUB:
    CNT = 0
    rd1 = 0

    goto main
    end

    '--------------------------------------------------------------------------
    'Interrupt Handler
    '--------------------------------------------------------------------------

    disable

    INIT:

    pause 200
    high LED1
    pause 100

    INTCON.1 = 0

    RESUME

    ENABLE

    '--------------------------------------------------------------------------
    'routines
    '--------------------------------------------------------------------------
    GetCmd:

    select case cmd


    case 1 ' BLINK LED

    pause 100
    FOR CN = 0 TO 1
    HIGH LED1
    PAUSE 30
    LOW LED1
    PAUSE 30
    HIGH LED1
    PAUSE 30
    NEXT CN
    RETURN


    case 2 ' turn LED ON for 30 secs.

    PAUSE 100
    low spk
    pause 30000
    high spk
    RETURN


    end select
    -------------------------------------------------------------------------

    Its just that in case 2 subroutine... when i comment command "pause" the
    interrupt works fine, but the 30sec auto-off doesnt work. when i put back the "pause" command, auto-off enabled, but the interrupt wont work in between the 30sec delay.

    thanks again!

    -trebdms-
    keepin'itreal

  3. #3


    Did you find this post helpful? Yes | No

    Default

    I think the problem is the 30 sec pause itself. You need to split it up into small chunks. For example 300 x 10 ms each. This will allow the interrupt to take place every 10 ms if so needed. With the pause 3000 command the processor is can't do anything for 30 seconds because it's stuck in a do nothing loop and won't see the interrupt until the 30 seconds has elapsed.

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, 10: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, 03:35
  3. Help with Analog Interrupt
    By brid0030 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 13th February 2008, 19:14
  4. Interrupt Problem
    By Kamikaze47 in forum mel PIC BASIC Pro
    Replies: 15
    Last Post: - 16th November 2005, 21:58
  5. USART interrupt not interrupting right
    By Morpheus in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 6th March 2005, 02: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