16F877a Interupt driven Hserin


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

    Default 16F877a Interupt driven Hserin

    Hi all, after suffering with my previous problem I was wondering if someone
    has a sample code to do some interupt driven Hserin

    I need to do the following:

    Read a serial string at 9600bd containing a start command "#" then 5 variables of each 3 Decimal digits separated by a ";" (let's say byte in decimal presentation)

    then I need to read 5 AD values on RA0-RA4
    Then i need to write those variables to an LCD display 4x20)
    and send them back and to some the serial port using HSEROUT
    finally I need to write some variables or bits to some hardware
    ports like (PortB,PortE,PortD)

    Mean while I may receive an updated string on the serial port using HSERIN

    If I use the following example from Mister E to play with Hserin and interupt
    it works,


    ' Serial communication definition
    ' ===============================
    ' Using internal USART and MAX232 to interface to PC
    '
    RCSTA = $90 ' enable serial port,
    ' enable continuous receive
    '
    TXSTA = $24 ' enable transmit,
    ' BRGH=1
    '
    SPBRG = 103 ' set baudrate to 2400

    ' Alias definition
    ' ================
    '
    '
    RCIF VAR PIR1.5 ' Receive interrupt flag (1=full , 0=empty)
    TXIF VAR PIR1.4 ' Transmit interrupt flag (1=empty, 0=full)
    OERR var RCSTA.1 ' Overrun error
    CREN var RCSTA.4 ' Continuous receive

    ' Hardware initialisation
    ' =======================
    '
    '
    pause 10 ' safe start-up delay

    Main:
    if oerr then ' Overrun error?
    cren=0 ' clear it
    cren=1
    endif

    if RCIF then ' incomming data?
    TXREG=RCREG ' take it, send it
    while TXIF=0 ' wait untill transmit buffer is empty
    wend
    endif
    goto main


    But as soon as I add multiple commands like Hserout,LCDout,etc...

    I miss some values on the HSERIN or get stucked on the "WAIT" command

    Any help or example how to do a proper interupt driven HSERIN while
    still displaying on the LCd and HSEROUT ?

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    I doubt that a tight loop and a register polling method will work. try working around the example 2 of this one
    http://www.picbasic.co.uk/forum/show...1&postcount=11
    In the ISR you may set a flag to tell the main to read the ADCs. To avoid waste of time and void some interrupts, i would recommend to set/read the ADCs register instead of using ADCIN. A short asm Delay loop, or use internal timer, OR a tight PAUSEUS x loop for your acquisition time.

    The use of instant interrupts OR asm, could be the best and smarter choice. Rule #1, never waste your time in ISR... this is what 'Wait' do ?.

    Let us know what's happen now.
    Last edited by mister_e; - 2nd November 2006 at 17:54.
    Steve

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

  3. #3
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    if someone has a sample code to do some interupt driven Hserin
    Quite a few...
    http://www.picbasic.co.uk/forum/sear...ess&query=rcif
    --and--
    http://list.picbasic.com/cgi-bin/boa...ALL&query=rcif
    DT

Similar Threads

  1. Help! My 'interupt', erhm ...only interupts the one time?!!!
    By HankMcSpank in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 2nd November 2009, 12:49
  2. HSERIN & Interupts (aka controlling PIC programs from a remote PC)
    By HankMcSpank in forum mel PIC BASIC Pro
    Replies: 16
    Last Post: - 17th June 2009, 14:46
  3. 16F877A HSERIN problem
    By RFsolution in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 30th October 2006, 02:51
  4. Clock connection to DS1802 from 16F877A
    By coyotegd in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 3rd January 2006, 18:52
  5. Hserin
    By egberttheone in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 27th November 2004, 15:42

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