PIC Interrupt help

Discussion in 'Embedded Systems and Microcontrollers' started by electronic_noob, Feb 9, 2010.

  1. electronic_noob

    Thread Starter Member

    Jan 15, 2010
    42
    1
    I need help on my pic program, the program goes like this the combination of LED to be turned ON depends on the input from serin but I want to put an interrupt so that when the interrupt is enabled all LED would be turned on..., I couldn't make it work is it possible that there is some conflict on the serin with interrupt?

    Im planning to let the pic read first the last input that when there would be black out it would still retain it's last input , thats why the program is written that way. my problem is interrupt, I want it that if there is voltage in Rb0 all the LED would be high please help me.


    this is the code:

    @ DEVICE pic16F628A,INTOSC_OSC_NOCLKOUT
    @ DEVICE pic16F628A,WDT_OFF
    @ DEVICE pic16F628A,CPD_OFF
    @ DEVICE PIC16F628A,PROTECT_OFF
    @ DEVICE PIC16F628A,BOD_OFF
    @ DEVICE PIC16F628A,LVP_OFF
    @ DEVICE PIC16F628A,MCLR_OFF

    TRISB = %00000011
    TRISA = %00000000
    CMCON=7
    Include "modedefs.bas"
    MARCUS VAR BYTE
    B0 VAR BYTE
    LED VAR PORTB.3
    TRUE CON 1
    FALSE CON 0
    LOW PORTB.3
    LOW PORTB.4
    LOW PORTB.5
    LOW PORTB.6
    OPTION_REG = %00111111
    On Interrupt Goto myint ' Define interrupt handler
    INTCON = %10010000



    START

    SERIN PORTB.1,2,["U"],MARCUS
    SEROUT PORTB.2,2,["ERROR",10,13]

    IF MARCUS.0=TRUE THEN
    HIGH PORTB.3
    ELSE
    LOW PORTB.3
    ENDIF
    IF MARCUS.1=TRUE THEN
    HIGH PORTB.4
    ELSE
    LOW PORTB.4
    ENDIF
    IF MARCUS.2=TRUE THEN
    HIGH PORTB.5
    ELSE
    LOW PORTB.5
    ENDIF
    IF MARCUS.3=TRUE THEN
    HIGH PORTB.6
    ELSE
    LOW PORTB.6
    ENDIF





    GOTO START


    Disable 'No interrupts past this point
    myint:

    PORTB.3 = FALSE
    PORTB.4 = TRUE
    PORTB.5 = TRUE
    PORTB.6 = TRUE
    pause 500

    INTCON.1 = 0 ' Clear interrupt flag
    Resume ' Return to main program
    Enable
     
    Last edited: Feb 15, 2010
  2. bertus

    Administrator

    Apr 5, 2008
    15,649
    2,348
    Hello,

    The picture is not visible as it is a local file on your own computer.
    You can upload the picture using the manage attachments button.

    Greetings,
    Bertus
     
  3. electronic_noob

    Thread Starter Member

    Jan 15, 2010
    42
    1
    I do not intend to include any image, it's just a mistake...I'm sure with my connections in the circuit all want is the interrupt thing, I cant seem to use interrupt when I use serin. MY pic is 16f628A...Rb0 is interrupt all connection is fine but the program I want to modify to suit what I have posted previously

    thanks a lot in advance
     
  4. Markd77

    Senior Member

    Sep 7, 2009
    2,803
    594
    I don't understand BASIC so I might be very wrong, but here goes:
    You use goto myint - should this be call?
    At the end there is resume, then enable. Should it be the other way round?
     
  5. electronic_noob

    Thread Starter Member

    Jan 15, 2010
    42
    1

    ah yes I think, I just want to ask if its possible that the interrupt function is disabled because Im using SERIN command, because I tried the interrupt on a simple function and it does work but as I added some code specifically the serin the interruot seems to fail to function, the interrupt is on RB0 and to enable it I connect it to the ground. Am I missing something?
     
  6. electronic_noob

    Thread Starter Member

    Jan 15, 2010
    42
    1


    its working but..., I cant seem to have that fast response in multiple inputs...but it does work
     
    Last edited: Feb 11, 2010
Loading...