Hserin with Instant Interrupts.


Closed Thread
Results 1 to 18 of 18

Hybrid View

  1. #1
    Join Date
    Feb 2013
    Location
    Quebec, Canada
    Posts
    67

    Default Re: Hserin with Instant Interrupts.

    This is what I do with DT_Interrupts on a serial stream of 115kBps on a PIC18F25k22 @44.2368MHz.

    "Buffer" is a circular buffer of 256 bytes. When BufferReady = 1, I use another pointer (ParsePtr) to parse the data.


    Code:
    '----[interrupts Handlers]-------------------------------------------------------
    RX_IntHandler:
        IF (RCSTA1.2 = 1) THEN
            ' A framing error occurred.
            ' Read RCREG to clear the error but don't use the data.
            CharBuff = RCREG1
    
        ELSE
           ' No framing error occurred. Get caracter.
           CharBuff = RCREG1
    
            If CharBuff <= 10 Then
                Buffer(BuffPtr) = 0
                BuffPtr = BuffPtr + 1
                BufferReady = 1
    
            Else
                If CharBuff >= 32 Then
                    Buffer(BuffPtr) = CharBuff
                    BuffPtr = BuffPtr + 1
                ENDIF
            ENDIF
        ENDIF
    
        @ INT_RETURN

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,624

    Default Re: Hserin with Instant Interrupts.

    Hi Andy,

    Looking at the original code I think at least one problem is the presense of the PAUSE in main routine.

    When using ON INTERRUPT the interrupt flag is checked in between each PBP statement. If characters start to come in while the PIC is exectuing a PAUSE 150 satements you're going to flood the USART buffer since the interrupt isn't serviced untill after the PAUSE 150 finishes.

    Same thing with the LCDOUT and PAUSE statements and in the master. They takes some time to execute and the interrupt flag is checked ONLY in between each statement so if the slave starts responding while the master is in the middle of printing to the LCD or executing a PAUSE the slave is going to flood the buffer of the master.

    That's the downside of ON INTERRUPT.

    /Henrik.

Similar Threads

  1. Instant Interrupts - Revisited
    By Darrel Taylor in forum Code Examples
    Replies: 772
    Last Post: - 17th February 2016, 23:14
  2. Clock using Instant Interrupts
    By PICpocket in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 16th February 2009, 22:43
  3. Instant Interrupts and HSERIN
    By Rob in forum mel PIC BASIC Pro
    Replies: 26
    Last Post: - 31st January 2009, 06:13
  4. DT instant interrupts with mister_e keypad
    By Tomexx in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 26th November 2008, 21:02
  5. DT's Instant Interrupts trouble
    By Tomexx in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 24th November 2008, 21:48

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