hserin buffer


Closed Thread
Results 1 to 9 of 9

Thread: hserin buffer

  1. #1

    Default hserin buffer

    Why only a 2 byte hserin buffer? I'm communicating with MIDI (baud 31250) and I'm not seeing any way to check the hserin fast enough to prevent overflow. It over flows when I get a big packet of straight bytes.

    Any tips or tricks?

  2. #2
    Join Date
    Sep 2009
    Posts
    737


    Did you find this post helpful? Yes | No

  3. #3


    Did you find this post helpful? Yes | No

    Default Re: hserin buffer

    I read what you posted in the link. I saw the UART recieve interupt but I'm not sure what an interupt is and how it will help me.

  4. #4
    Join Date
    Sep 2009
    Posts
    737


    Did you find this post helpful? Yes | No

    Default Re: hserin buffer

    eg
    http://www.picbasic.co.uk/forum/showthread.php?t=11320
    Then just put received chars in array
    Code:
    Get_char:
         hserin 100,noreceived,[mybyte] 'Get byte
         MyArray[Index]=mybyte
         Index=Index+1
         noreceived: 'or if timeout return
    @ INT_RETURN

  5. #5


    Did you find this post helpful? Yes | No

    Default Re: hserin buffer

    Pedja089 ... Can you explain in more detail. What i think im reading is this code sets up the hserin to continously read into an array and the program simply needs to check that array?

  6. #6
    Join Date
    Sep 2009
    Posts
    737


    Did you find this post helpful? Yes | No

    Default Re: hserin buffer

    When byte is received, PIC jump to Get_char, and get one char, and put it in array. Then PIC goes to do what it was doing before interrupt...

  7. #7
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,802


    Did you find this post helpful? Yes | No

    Default Re: hserin buffer

    What pedja089 posted on #4 is a Interrupt Service Routine (ISR) that is part of a bigger program.

    Interrupts might be a difficult subject for the novice, so you have to break your project in small parts and test each part, ensuring you understand the steps you take.

    Darrel Taylor has put up this extremely helpful packet for 16 or 18 series PIC controllers but to understand how to do it you have to read a little.

    Example (untested):

    1. setup the ISR for the serial receive:

    Code:
    ASM
        INT_LIST  macro    ; IntSource,        Label,  Type, ResetFlag?
                INT_Handler   RX_INT,	 _Get_char,		 PBP,  yes
        endm
        INT_CREATE               ; Creates the interrupt processor
    ENDASM
    Whenever you are ready to receive characters place this command

    @ INT_ENABLE RX_INT

    Your ISR could be the above posted:

    Code:
    Get_char:
         hserin 100,noreceived,[mybyte] 'Get byte
         MyArray[Index]=mybyte
         Index=Index+1
         If index>max_array-1 then
             index=0
             flag_endarray_reached=1
         EndIf
         noreceived: 'or if timeout return
    @ INT_RETURN
    Now every time there is a character available it will be put in the array mybyte untill the end is reached.
    Then it will wrap arround and a flag will be set so you know that the array was filled up.

    Don't forget to include the appropriate files of the DT-INTS for your chip used.

    HTH,
    Ioannis

  8. #8
    Haman03's Avatar
    Haman03 Guest


    Did you find this post helpful? Yes | No

    Default Re: hserin buffer

    Hserin buffer 16F87x serires input and output buffers are each 47 bytes.

  9. #9
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,802


    Did you find this post helpful? Yes | No

    Default Re: hserin buffer

    If you mean the hardware buffer, then NO. It is only 2 bytes deep.

    Ioannis

Similar Threads

  1. Replies: 2
    Last Post: - 27th July 2011, 21:06
  2. Replies: 3
    Last Post: - 12th February 2007, 18:32
  3. EasyHID and buffer entry 0
    By Demon in forum USB
    Replies: 0
    Last Post: - 19th August 2006, 19:34
  4. Input buffer
    By jrt4fun in forum Schematics
    Replies: 3
    Last Post: - 23rd March 2005, 07:49
  5. TX RX Buffer Question
    By shawn in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 14th January 2005, 01:49

Members who have read this thread : 1

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