high low priority interrupt.


+ Reply to Thread
Results 1 to 12 of 12

Thread: high low priority interrupt.49 days old

  1. #1
    Member amateurtje's Avatar
    Join Date
    Aug 2008
    Posts
    151
    Thumbs Up
    Received: 4
    Given: 3
    Total Downloaded
    488.93 MB

    0 Not allowed!

    Default high low priority interrupt.

    Hello all,

    Because my interrupt cycle was getting bigger and bigger and a stopwatch and pulse counting has a very high priority over the serial communication, I divided the interrupt in a high and low priority part.

    the device blocks sometimes completely when pulses and serial data is coming in.

    The problem is that I used "Context Save" and "Context restore" for both.
    the FSR0Reg/Retfie fast meothod gives me problems with the stopwatch (TMR1).. Even without any serial communication and even without Pulse counting, the stopwatch goes very slow and stops completely...
    This is my interrupt code.

    Can anybody help me?

    My PIC is a 18F46k22.



    Code:
     ;    Dim FSR0Reg As FSR0L.Word
    INTERRUPT_ROUTINE:
     FSR0_SAVE = FSR0Reg''Context Save;   
    
    
    
    
    If TMR1IF= 1 Then                                 ; TMR1 voor de stopwatch
      Clear TMR1ON                                   ' STOP TMR1
      TIMER1REG = TIMER1REG + TMR1_VAL                ' LOAD TMR1
      Set TMR1ON                                     ' START TMR1
      Inc swTijdophoging                               ;verhoog de tijd met 1 (dit is iedere 0,25 seconde)
      Inc tijdswTijdophoging
      Inc Snelheidsophoging
      Inc Snelheidsophoging2
      Clear TMR1IF                                            ' CLEAR TMR1 INTERRUPT FLAG
    EndIf
    
    
    If ccp4IF = 1 Then
      OldTijd2 = Tijd2
        Tijd2   = (256*CCPR4H) + CCPR4L
      Oldsnelheidsophoging2 = Snelheidsophoging2
      Snelheidsophoging2 = 0   
      If Richting = 0 Then Inc Pulse[1]
      If Richting = 2 Then Dec Pulse[1]
    ccp4IF = 0
    End If
    
    
    
    
    If ccp5IF = 1 Then
      OldTijd = Tijd
        Tijd   = (256*CCPR5H) + CCPR5L
      Oldsnelheidsophoging = Snelheidsophoging
      Snelheidsophoging = 0   
      If Richting = 0 Then Inc Pulse[0]
      If Richting = 2 Then Dec Pulse[0]
        ccp5IF = 0
    End If
    
    
        FSR0Reg = FSR0_SAVE
        Retfie Fast         ' Context Restore
    
    
    ISR_Low:
    Context Save
      
    If RCIF = 1 Then
         InterruptByte =ontvang
        If FERR = 1 Or OERR = 1 Then
            CREN = 0
            bRec =0
            FERR =0
            iRec = 0
            Rtrigger = 0
            RCIF = 0
            CREN=1
        Else
       $ifdef GPSaan''     If GPSaan = True Then
            Select Case Rtrigger
                Case 0
                    If InterruptByte = $ Then Rtrigger = 1: Else: Rtrigger =0
                Case 1
                    If InterruptByte = "G" Then Rtrigger = 2: Else: Rtrigger =0            
                Case 2
                      If InterruptByte = "P"   Then
                       Rtrigger = 3
                         GPS_IsN  = False
                        Else
                         Rtrigger =0   
                      EndIf
                      If  InterruptByte = "N" Then
                       Rtrigger = 3
                         GPS_IsN  = True
                        Else
                         Rtrigger =0   
                      End If
                Case 3
                     If InterruptByte = "R" Or InterruptByte = "G" Then Rtrigger = 4: Else: Rtrigger =0 
                Case 4
                      If InterruptByte = "M" Or InterruptByte = "G" Then Rtrigger = 5: Else: Rtrigger =0
               Case 5
                    If InterruptByte = "C" Then 
                        Rtrigger = 6
                        GPS_SatChecker =False 
                    Else
                        If InterruptByte = "A" Then 
                            Rtrigger = 6
                            GPS_SatChecker =True
                        Else
                            Rtrigger =0
                       End If
                    End If 
                Case 6
                    If InterruptByte = "," Then Rtrigger = 7: Else: Rtrigger =0
                              
                Case 7
                     Rtrigger = 8
                Case 8
                Case Else
                    Rtrigger =0
            End Select
    
    
            If Rtrigger = 8 Then
            If GPS_SatChecker =True Then
                    GPS_InfoSatCheck[iRec] = InterruptByte
                   If iRec = 65 Then 
                       bRec = 2
                        Rtrigger =0 
                        iRec = 0 
                    Else
                        If iRec < 65 Then Inc iRec           
                    EndIf                
             Else
                        GPS_Info[iRec] = InterruptByte
                    If iRec = 65 Then 
                        If GPS_IsN = True Then
                        bRec = 3 
                        Else
                       bRec = 1
                        End If
                        Rtrigger =0 
                        iRec = 0 
                    Else
                        If iRec < 65 Then Inc iRec           
                    EndIf 
               End If
            End If
         $else   ;; IN NIET GPS MODE
         
           Select Case Rtrigger
                Case < 3
                    If InterruptByte = 255 Then
                        Rtrigger = Rtrigger + 1
                    Else
                        Rtrigger = 0
                    End If
                    totaal =0
                Case > 2
    
    
                     If     ONtvangstindicator >0 Then
                        ffbyte2 = interruptbyte
                        If rtrigger>602 Then
                            If rtrigger = 607 Then
                                If totaal = ffbyte2 Then
                                    brec = 2
                                    Rtrigger = 0
                                    iRec = 0
                                Else
                                    brec = 0
                                    Rtrigger = 0
                                    iRec = 0   
                                End If
                            End If
                        Else 
                            totaal = totaal + ffbyte2
                            ffbyte =  (rtrigger-3)//8 
                            ffbyte1 = (rtrigger-3) /8   '' Deze net naar -3 gezet...
                            Select Case ffbyte
                                Case 0
                                    receivebuffer1[ffbyte1]  = ffbyte2''InterruptByte
                                Case 1
                                    receivebuffer2[ffbyte1]  = ffbyte2''InterruptByte
                                Case 2
                                    receivebuffer3[ffbyte1]  =ffbyte2'' InterruptByte
                                Case 3
                                    receivebuffer4[ffbyte1]  =ffbyte2'' InterruptByte
                                Case 4
                                    receivebuffer5[ffbyte1]  =ffbyte2'' InterruptByte
                                Case 5
                                    receivebuffer6[ffbyte1]   = ffbyte2''InterruptByte
                                Case 6
                                    receivebuffer7[ffbyte1]  = ffbyte2''InterruptByte
                                Case 7
                                    receivebuffer8[ffbyte1]         =ffbyte2'' InterruptByte
                            End Select
                        End If 
                         Rtrigger = Rtrigger + 1
                   Else
                    aBuff[iRec] = InterruptByte
                    Rtrigger = Rtrigger + 1
                    Inc iRec
                    If iRec = 5 Then
                        Totalbuff = aBuff[0] + aBuff[1] + aBuff[2] + aBuff[3]
                        If Totalbuff = aBuff[4] Then
                            bRec = 1
                            Rtrigger = 0
                            iRec = 0
                        Else
                            bRec = 0
                            Rtrigger = 0
                            iRec = 0                          
                        End If 
                    EndIf
                    End If
           End Select
         $endif
       End If
    End If
    Context Restore

  2. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  3. #2
    Fanatical Contributor top204's Avatar
    Join Date
    Feb 2002
    Posts
    3,794
    Thumbs Up
    Received: 375
    Given: 182
    Total Downloaded
    2.09 GB

    0 Not allowed!

    Default Re: high low priority interrupt.

    You will need to use Context Save and Context Restore in the High Priority interrupt handler as well, because you have some expressions within it that will alter the device's SFRs, and create compiler system variables.

    Using a non-context interrupt handler can only be done when the interrupt is exremely simple.

  4. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  5. #3
    Member amateurtje's Avatar
    Join Date
    Aug 2008
    Posts
    151
    Thumbs Up
    Received: 4
    Given: 3
    Total Downloaded
    488.93 MB

    0 Not allowed!

    Default Re: high low priority interrupt.

    but will this not cause a problem, using for both Context save and context restore?

    I thought/hoped/suspected that the problem of blocking sometimes when there is serial communication while pulses are coming in, was due to the double use of Context save and restore. I read on this forum that it is not allowed to use them on both interrupts...

  6. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  7. #4
    Member amateurtje's Avatar
    Join Date
    Aug 2008
    Posts
    151
    Thumbs Up
    Received: 4
    Given: 3
    Total Downloaded
    488.93 MB

    0 Not allowed!

    Default Re: high low priority interrupt.

    Sorry, i can not edit my post anymore... another thought I had reading your (Les) his comments on other related posts. There is written that you have to reset an interrupt flag at the end of its handler to avoid another (same) interrupt coming in twice. in the low prio interrupt, there is a big serial reading part and I can understand that due to the stopwatch and pulses that can come in during serial reading, this interrupt is delayed and therefore reactivated by second information coming in.. the interrupt is resetted by reading the serial information byte (first line, low prio interrupt "ontvang" = RCREG2). that is not possible to do at the last line.... maybe I should somehow stop the serialinterrupt a different way?

    I thought of reading only the byte and do all the handling in the normal program but I think that is way to slow to handle everything in time.. it has become a full and long program with a lot of print to the screen etc. therefore the interrupt is a bit bigger, although there is a big part ($if-$end if) of the below script that is not used at the moment. this is the main raason for the low priority. if something is not received well in the serial communication, it is a pitty, but no real problem.. people have to send their data a second time....
    However, if the device is blocked, the stopwatch not exactly corret or the pulses not read, it is a big deal breaker ..

    Another thought, is ther eanother way of sotring restoring the low priority interrupt (or do you not think my problem is related to the double use of context save/restore)?
    Last edited by amateurtje; 10th October 2020 at 09:00.

  8. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  9. #5
    Prolific Poster towlerg's Avatar
    Join Date
    Mar 2012
    Posts
    2,398
    Thumbs Up
    Received: 87
    Given: 183
    Total Downloaded
    5.30 GB

    0 Not allowed!

    Default Re: high low priority interrupt.

    Purely my personal opinion but I think you're trying to do too much in the IRQ routine. Perhaps some of that work could be done in the main body in response to flags set in the IRQ? What speed are you running the K22?
    George.

  10. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  11. #6
    Member amateurtje's Avatar
    Join Date
    Aug 2008
    Posts
    151
    Thumbs Up
    Received: 4
    Given: 3
    Total Downloaded
    488.93 MB

    0 Not allowed!

    Default Re: high low priority interrupt.

    Hi Towlerg,

    As I wrote, indeed, I think it would be better to do less in the low priority, but still, in theory, the problem remains, even when doing very little in the low prio interrupt. only the probability diminishes but I can not have the system blocking. Even with a lower chance.... Becasue the interrupt for serial communication was growing, I went to a low priority interrrupt....

    I am running at 20Mhz. I understand I can higher this but that means changing a some things... to keep the calculations for the stopwatch almost the same, I was thinking of maybe highering the crystal to 40Mhz. I do not have a (very accurate) 40Mhz in my collection.....

  12. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  13. #7
    Member amateurtje's Avatar
    Join Date
    Aug 2008
    Posts
    151
    Thumbs Up
    Received: 4
    Given: 3
    Total Downloaded
    488.93 MB

    0 Not allowed!

    Default Re: high low priority interrupt.

    In the meantime I received my 40Mhz crystals and I installed them. As expected, only these crystals did not solve the problem. Completely logical ofcourse, but it is a good step.

    While I do not see a good alternative for the Context Save- Context restore commands, (please still feel free to suggest alternatives!!!), I think I need to go back to 1 Interrupt again. In the same process I would like to see if I can reduce the amount of code for the Serial receipt script with a good buffersize. Anybody a good example for me, please?

    What the code is doing:
    I send/receive first 3 times 255 to recognise the start. Then there are 2 word values; the address and the value and after that, there is a sum of the address and value. This sum value is a checkvalue.

    My existing code (with deleting some irrelevant optional code):
    Code:
    ISR_Low:
    Context Save
      
    If RCIF = 1 Then
         InterruptByte =ontvang
        If FERR = 1 Or OERR = 1 Then
            CREN = 0
            bRec =0
            FERR =0
            iRec = 0
            Rtrigger = 0
            RCIF = 0
            CREN=1
        Else
           Select Case Rtrigger
                Case < 3
                    If InterruptByte = 255 Then
                        Rtrigger = Rtrigger + 1
                    Else
                        Rtrigger = 0
                    End If
                    totaal =0
                Case > 2
    
    
                     If     ONtvangstindicator >0 Then
                        ffbyte2 = interruptbyte
                        If rtrigger>602 Then
                            If rtrigger = 607 Then
                                If totaal = ffbyte2 Then
                                    brec = 2
                                    Rtrigger = 0
                                    iRec = 0
                                Else
                                    brec = 0
                                    Rtrigger = 0
                                    iRec = 0   
                                End If
                            End If
                        Else 
                            totaal = totaal + ffbyte2
                            ffbyte =  (rtrigger-3)//8 
                            ffbyte1 = (rtrigger-3) /8   '' Deze net naar -3 gezet...
                            Select Case ffbyte
                                Case 0
                                    receivebuffer1[ffbyte1]  = ffbyte2''InterruptByte
                                Case 1
                                    receivebuffer2[ffbyte1]  = ffbyte2''InterruptByte
                                Case 2
                                    receivebuffer3[ffbyte1]  =ffbyte2'' InterruptByte
                                Case 3
                                    receivebuffer4[ffbyte1]  =ffbyte2'' InterruptByte
                                Case 4
                                    receivebuffer5[ffbyte1]  =ffbyte2'' InterruptByte
                                Case 5
                                    receivebuffer6[ffbyte1]   = ffbyte2''InterruptByte
                                Case 6
                                    receivebuffer7[ffbyte1]  = ffbyte2''InterruptByte
                                Case 7
                                    receivebuffer8[ffbyte1]         =ffbyte2'' InterruptByte
                            End Select
                        End If 
                         Rtrigger = Rtrigger + 1
                   Else
                    aBuff[iRec] = InterruptByte
                    Rtrigger = Rtrigger + 1
                    Inc iRec
                    If iRec = 5 Then
                        Totalbuff = aBuff[0] + aBuff[1] + aBuff[2] + aBuff[3]
                        If Totalbuff = aBuff[4] Then
                            bRec = 1
                            Rtrigger = 0
                            iRec = 0
                        Else
                            bRec = 0
                            Rtrigger = 0
                            iRec = 0                          
                        End If 
                    EndIf
                    End If
           End Select
       End If
    End If
    Context Restore
    Last edited by amateurtje; 23rd October 2020 at 11:44.

  14. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  15. #8
    Member Dompie's Avatar
    Join Date
    Apr 2012
    Posts
    182
    Thumbs Up
    Received: 19
    Given: 15
    Total Downloaded
    5.19 GB

    0 Not allowed!

    Default Re: high low priority interrupt.

    I don't know what you want to happen but I think the Select Case Rtrigger Else never runs.
    First Case Rtrigger < 3 so Rtrigger= 0, 1 or 2 and then the next Case Rtrigger > 2 so Rtrigger= 3-255 so the else is never used.

    Johan

  16. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  17. #9
    Member amateurtje's Avatar
    Join Date
    Aug 2008
    Posts
    151
    Thumbs Up
    Received: 4
    Given: 3
    Total Downloaded
    488.93 MB

    0 Not allowed!

    Default Re: high low priority interrupt.

    Quote Originally Posted by Dompie View Post
    I don't know what you want to happen but I think the Select Case Rtrigger Else never runs.
    First Case Rtrigger < 3 so Rtrigger= 0, 1 or 2 and then the next Case Rtrigger > 2 so Rtrigger= 3-255 so the else is never used.

    Johan
    Hi Johan,

    This script runs, and runs already a while. Only it hass become bigger and bigger. While my other items that the interrupt is doing, is very important to never miss a pulse or timing trigger, I tried to use a low prio interrupt which seems to be a mystery..

    Incoming is for example : 255 255 255 0 2 0 234 236, according the description in my last post.

    First 255 comes in.
    Rtrigger becomes 1
    Then 255 comes in: Rtrigger becomes 2
    Then 255 comes in: RTrieeger becomes 3.
    Then it starts reading the address and value (with checksum)

    So it waits untill 3xtimes 255 came in.

    There is no Case Else..... This CASE statement could have been an if/then statement.... When I was starting to write, I thought to have more options but this never happend.
    The ELSE statement belong to the If statements. They are not so nice aligned.


    Quote Originally Posted by Dompie View Post
    I don't know what you want
    1. I was using low and high priority Interrupts but that seems not possible with my scripts while it needs 2 times Context save and Context restore but this gives problems.... So I was looking for solution but this does not seem to exist. The retfie command does not seem to work for my high interrupt..........

    2. While the low priority serial receipt script has become long, I was looking for some help for a good script to receive the data in a buffer and read this buffer later. (while data can come in!!)

  18. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  19. #10
    Member Dompie's Avatar
    Join Date
    Apr 2012
    Posts
    182
    Thumbs Up
    Received: 19
    Given: 15
    Total Downloaded
    5.19 GB

    0 Not allowed!

    Default Re: high low priority interrupt.

    Ohhhh yeah I see it. If I had read correctly I would have seen that it is 'else' and not 'case else'.
    I will buy new glasses.

    Johan

  20. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  21. #11
    Member amateurtje's Avatar
    Join Date
    Aug 2008
    Posts
    151
    Thumbs Up
    Received: 4
    Given: 3
    Total Downloaded
    488.93 MB

    0 Not allowed!

    Default Re: high low priority interrupt.

    Quote Originally Posted by Dompie View Post
    Ohhhh yeah I see it. If I had read correctly I would have seen that it is 'else' and not 'case else'.
    I will buy new glasses.

    Johan
    I am glad you try to help! and you may have mine...I really hate them but getting older is not always fun......

  22. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  23. #12
    Senior Member tumbleweed's Avatar
    Join Date
    May 2011
    Posts
    545
    Thumbs Up
    Received: 61
    Given: 0
    Total Downloaded
    519.78 MB

    0 Not allowed!

    Default Re: high low priority interrupt.

    You should be able to use CONTEXT SAVE/CONTEXT RESTORE in both the high-priority and low-priority interrupts.
    They use two different regions to save the context, so that part shouldn't be an issue.

    If you want to have the TMR and CCP take priority over the serial handling then you should use the two priorities
    the way you had it initially.

    It would really help if you would post a complete example that compiles, so without that I had to make a number of assumptions
    that may be right or wrong. Here are some suggestions...

    In the high-isr:

    If you have TMR1 setup for 16-bit read/write mode (T1CON.RD16=1) then this won't work:
    Code:
          TIMER1REG = TIMER1REG + TMR1_VAL                ' LOAD TMR1
    In 16-bit mode the TMR1H register is latched when you read/write to TMR1L, and that statement
    doesn't follow that... it operates on TMR1L then TMR1H, so set T1CON.RD16=0

    You don't have to clear the IF flags at the end. You should clear the IF flags as soon as you do
    whatever you need to handle the peripheral.
    For example
    Code:
        If TMR1IF= 1 Then                                ' TMR1 voor de stopwatch
          Clear TMR1ON                                   ' STOP TMR1
          TIMER1REG = TIMER1REG + TMR1_VAL               ' LOAD TMR1
          Clear TMR1IF                                   ' CLEAR TMR1 INTERRUPT FLAG
          Set TMR1ON                                     ' START TMR1
          Inc swTijdophoging                               ;verhoog de tijd met 1 (dit is iedere 0,25 seconde)
          Inc tijdswTijdophoging
          Inc Snelheidsophoging
          Inc Snelheidsophoging2
        EndIf
    That will help you possibly avoid missing future interrupts.

    For the CCP sections, you can speed them up by replace the statement to read the 16-bit CCPRx registers
    Code:
        Tijd2   = (256*CCPR4H) + CCPR4L
    with
    Code:
        Tijd2.HighByte = CCPR4H
        Tijd2.LowByte = CCPR4L
    so that ends up looking more like:
    Code:
        If CCP4IF = 1 Then
          oldTijd2 = Tijd2
          Tijd2.HighByte = CCPR4H
          Tijd2.LowByte = CCPR4L
          CCP4IF = 0
          Oldsnelheidsophoging2 = Snelheidsophoging2
          Snelheidsophoging2 = 0   
          If Richting = 0 Then Inc pulse[1]
          If Richting = 2 Then Dec pulse[1]
        End If
    Do the same with CCP5.

    Finally, get rid of 'FSR0_SAVE', 'FSR0Reg = FSR0_SAVE', 'Retfie Fast' and replace them with Context Save/Context Restore


    Now, in the low-isr:
    I'll leave it up to you to determine if the logic for all that is correct or not.
    I wouldn't do all that in the isr, but that's just me.

    There is one part that might be an issue...
    Code:
    If RCIF = 1 Then
        InterruptByte =ontvang
        If FERR = 1 Or OERR = 1 Then
            CREN = 0
            bRec =0
            FERR =0
            iRec = 0
            Rtrigger = 0
            RCIF = 0
            CREN=1
    The 'If FERR = 1 Or OERR = 1' statement uses a system variable 'SP__P9_', and that variable was not being saved
    by CONTEXT SAVE in the test code I tried. For the time being, try changing that test to just 'If OERR = 1'
    A framing error will not stop the uart from working like an over-run error does, so you don't really need all that anyway.
    Remove the 'RCIF = 0' since RCIF is a read-only flag and only clears when you read the RCREG.

  24. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. Strange behaviour of low priority interrupt on 18F26K80
    By paulc in forum Proton Plus Compiler v3
    Replies: 7
    Last Post: 21st November 2013, 09:57
  2. High and low priority of interrupt in 16Fxxx devices
    By pak in forum Proton Plus Compiler v3
    Replies: 6
    Last Post: 2nd November 2010, 16:21
  3. High/low Interrupt Servise Help
    By SELCUK in forum Proton Plus Compiler v3
    Replies: 0
    Last Post: 14th January 2009, 10:27
  4. [SOLVED !] Low priority interrupt stops responding.
    By Kingjamez in forum Proton Plus Compiler v3
    Replies: 2
    Last Post: 31st March 2008, 01:13
  5. [SOLVED !] Context save and Low priority interrupts
    By Hans Chr in forum Proton Plus Compiler v3
    Replies: 3
    Last Post: 24th October 2005, 12:54

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts