RX interrupt


Closed Thread
Results 1 to 7 of 7

Thread: RX interrupt

Hybrid View

  1. #1
    Join Date
    Mar 2010
    Posts
    3

    Default RX interrupt

    Hello,
    first of all, im new on this forum and i'm from the Netherlands (spelling issue)

    since a month, im programming PIC controllers for school. im using a big, pic16f877a device which have alot of functions, including interrupts.

    However those interrupts dont work for me. I wrote a code, just to interrupt when serial data is incomming.
    Heres the code:
    Code:
    ;DEFINE HSER_RCSTA 90h (no function if baud rate is defined)
    ;DEFINE HSER_TXSTA 20h (no function if baud rate is defined)
    define HSER_BAUD 9600
    DEFINE HSER_SPBRG 25
    define osc 20
    Include "modedefs.bas"
    
    ON INTERRUPT GOTO INTERRUPT_HANDLER
    INTCON = %11000000
    PIE1.5 = 1 ' enable interrupt on usart receive
    
    
    Main_Loop:
    low portd.2
    pause 500
    hserout ["main loop hser"]
    GOTO Main_Loop
    END
    
    DISABLE INTERRUPT
    INTERRUPT_HANDLER:
    high portd.2
    hserout ["Interrupt handler hser"]
    
    PIR1.5 = 0 'Receive int clear
    
    pause 1000
    RESUME
    ENABLE INTERRUPT
    When i power up the pic, interrupt is active (portd.2 is a led) and will glow up. Sending serial data to usart wont make any difference.

    Anybody who can help? or write a simple RX interrupt example?
    Thanks in advance.

  2. #2
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Arciure View Post
    Hello,
    first of all, im new on this forum and i'm from the Netherlands (spelling issue)

    since a month, im programming PIC controllers for school. im using a big, pic16f877a device which have alot of functions, including interrupts.

    However those interrupts dont work for me. I wrote a code, just to interrupt when serial data is incomming.
    Heres the code:
    Code:
    ;DEFINE HSER_RCSTA 90h (no function if baud rate is defined)
    ;DEFINE HSER_TXSTA 20h (no function if baud rate is defined)
    define HSER_BAUD 9600
    DEFINE HSER_SPBRG 25
    define osc 20
    Include "modedefs.bas"
    
    ON INTERRUPT GOTO INTERRUPT_HANDLER
    INTCON = %11000000
    PIE1.5 = 1 ' enable interrupt on usart receive
    
    
    Main_Loop:
    low portd.2
    pause 500
    hserout ["main loop hser"]
    GOTO Main_Loop
    END
    
    DISABLE INTERRUPT
    INTERRUPT_HANDLER:
    high portd.2
    hserout ["Interrupt handler hser"]
    
    PIR1.5 = 0 'Receive int clear
    
    pause 1000
    RESUME
    ENABLE INTERRUPT
    When i power up the pic, interrupt is active (portd.2 is a led) and will glow up. Sending serial data to usart wont make any difference.

    Anybody who can help? or write a simple RX interrupt example?
    Thanks in advance.
    Hello, and welcome to the forum.
    HSEROUT transmits HSERIN receives. That is where I would start . . . and understand , it must occur on the RX pin as defined in the Data Sheet. Additionally The hardware USART requires the RX port to "Idle High", which is to say, PULL UP Resistor required.
    Last edited by Archangel; - 3rd March 2010 at 18:22.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  3. #3
    Join Date
    Mar 2010
    Posts
    3


    Did you find this post helpful? Yes | No

    Default

    ok, i added a 10k resistor from RX to Vdd. And you´re right its now interrupting . however it doesnt return to the main program, and the serial data i receive is ""misformed" but it has the same sequence. I will try more things out now to make it work perfectly. Thx you

  4. #4
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Code:
    DISABLE INTERRUPT
    
    ENABLE INTERRUPT
    Should be
    Code:
    DISABLE
    
    ENABLE
    Dave
    Always wear safety glasses while programming.

  5. #5
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    And I don't know your hardware - but. You can't run the output of a PC serial port directly into a hardware serial port of a PIC, even with a resistor. The PC output is LOW when no character is transmitted, while the PIC expects a HIGH when no character is transmitted. If you use a level-shifter/inverter like a MAX232 between your PIC and PC, you don't need a resistor (pull-up or otherwise), and the inversion will be taken care of for you.
    Charles Linquist

  6. #6
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Charles Linquis View Post
    And I don't know your hardware - but. You can't run the output of a PC serial port directly into a hardware serial port of a PIC, even with a resistor. The PC output is LOW when no character is transmitted, while the PIC expects a HIGH when no character is transmitted. If you use a level-shifter/inverter like a MAX232 between your PIC and PC, you don't need a resistor (pull-up or otherwise), and the inversion will be taken care of for you.
    Or you could use a transistor to invert the P/C's inverted logic back to true. I first saw this method employed by P H Anderson in a serial LCD backpack I bought from him. Wulfden sells kits,based on his chips, and the schematic can be found here in his manual: http://www.wulfden.org/downloads/manuals/K107manual.pdf
    If you go there be sure to visit his products page. He even sells the bare PCB if you don't want the kits.
    http://www.wulfden.org/TheShoppe/products.shtml
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

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