USART with INTERRUPTS


Results 1 to 13 of 13

Threaded View

  1. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Try this instead....

    @ device hs_OSC, wdt_on, pwrt_on, protect_off
    define osc 20
    Include "modedefs.bas"
    RCSTA = %10010000:SPBRG = 31:INTCON = %11000000:PIE1.5=1:trisc.6=0
    TRISC.7=1:TRISA.0=0:test var porta.0:counter var word:BAUD CON 16390

    ---------------------------------jump over your interrupt routines
    goto main
    -----------------------------------------------------------------

    on interrupt goto myroutine

    disable
    myroutine:
    if PIR1.5=1 then
    serout2 test,BAUD,[dec rcreg,10,13] 'send the value to com2
    serout2 test,BAUD,["PIR1.5=",BIN PIR1.5,10,13]
    IF RCSTA.1=1 THEN
    serout2 test,BAUD,["BUFFER OVERRUN",10,13] 'Just to see if overflow occured
    ENDIF

    -------------------read the serial port input register and reset the input interrupt flag
    x=rcreg : PIR1.5 = 0

    endif
    resume
    enable

    main:
    if counter= 5000 THEN 'just to keep the pic busy to make sure the
    toggle portd.0:counter=0 ' interrupts are working.
    else
    counter=counter+1
    endif
    goto main

    end

    You're program organization was messed up a bit. Also, you have to read RCREG and reset the flag manually when using the serial port, just like the datasheet says.

    Which version of PBP are you using?
    Last edited by skimask; - 17th April 2007 at 15:08.

Similar Threads

  1. Instant Interrupts - Revisited
    By Darrel Taylor in forum Code Examples
    Replies: 772
    Last Post: - 17th February 2016, 22:14
  2. Clock using Instant Interrupts
    By PICpocket in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 16th February 2009, 21:43
  3. DT's Instant Interrupts trouble
    By Tomexx in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 24th November 2008, 20:48
  4. help: TMR0 interrupts disabling PORTAchange interrupts???
    By xnihilo in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 19th August 2008, 15:10
  5. problem with USART
    By leemin in forum Serial
    Replies: 4
    Last Post: - 11th December 2006, 17:56

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