do I need an interrupt?


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

    Default do I need an interrupt?

    Hello Everyone. I think I am in need of using an interrupt but can't get one to work. While constantly monitoring my inputs, I need another port to go high for approximately 1/2 second, go low for about 3 seconds and continue this until all of my inputs = 0. I can't use HIGH and PAUSE commands because it will miss the action on the inputs during the pause. I am also using both of the HPWM ports so I can't use them for this function either. If anyone can add some simple snippets in my code and briefly explain what is happening to accomplish this, I would greatly appreciate it.


    'COMPILED FOR 16F73
    adcon1 = 7 ' set inputs to digital
    @ DEVICE WDT_ON, BOD_ON, PWRT_ON, PROTECT_ON
    TRISA = %00100100 'RA2 & RA5 ARE INPUTS
    TRISB = %01111001 'RB0, 3, 4, 5, 6 ARE INPUTS
    TRISC = %00000001 'RC0 IS INPUT

    START:
    (MAKE THE MYSTERY PORT LOW)
    IF PORTB.0 = 0 THEN START

    WORK:
    (MAKE THE MYSTERY PORT HIGH FOR 500 AND LOW FOR 3000 MS WITHOUT MISSING ACTION ON INPUTS)
    DO SOMETHING HERE & THERE
    IF PORTB.0 = 0 THEN START
    GOTO WORK

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


    Did you find this post helpful? Yes | No

    Talking simple way

    Just drive pin 4 from the Mystery slave circuit ( 8 pins ooooooold timer , cmos version available, its generic number is 3 times 10 halves ... )

    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
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default Just a pointer

    OK, do a search for Timer interrupt first. in the interrupt routine you'll have to determine:
    1. i'm i on the HIGH pulse?... since how may time? enough? if so do the low pulse
    2. same as 1 for low pulse

    try it. If there's any other problem, i see some method.

    OR do a short pause loop, check the pin state in the loop.
    Steve

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

  4. #4


    Did you find this post helpful? Yes | No

    Default

    what I did was

    START:
    IF PORTB.0 = 0 THEN START

    WORK:
    DO SOMETHING HERE & THERE 'this takes 250ms to complete
    LET X = X + 1
    IF X > 333 THEN GOSUB GOHIGH
    IF PORTB.0 = 0 THEN START
    GOTO WORK

    GOHIGH:
    HIGH PORTC.3
    PAUSE 500
    LOW PORTC.3
    LET X = 0
    RETURN

    So, after about 3 seconds my port goes high for 500ms but I still have a 500ms + 250ms = 750ms gap where my inputs are ignored. A 555 one-shot would work fine but I want to avoid adding more circuitry if possible.

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


    Did you find this post helpful? Yes | No

    Wink And with a little " RTFM " ??????

    Hi,

    As all your inputs are on PortB ... why not use the simple feature " interrupt on PortB change " ???

    you just have to check which input caused the interrupt and do what needed ...

    That would not disturb your PWM sections nor make great changes to your tempo's, even if a basic interrupt used.

    ( note it's an Excellent excercise for trying Darrel's Instant interrupts, too ... )

    just change PAUSE 500 to

    For i = 1 to 500
    PAUSE 1
    Next i

    ... as stated in the MANUAL, Basic interrupts section ....


    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 " !!!
    *****************************************

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