Isr#s and Proc's


+ Reply to Thread
Results 1 to 11 of 11

Thread: Isr#s and Proc's1138 days old

  1. #1
    Prolific Poster johngb's Avatar
    Join Date
    Oct 2003
    Posts
    2,171
    Thumbs Up
    Received: 96
    Given: 1
    Total Downloaded
    2.91 GB

    0 Not allowed!

    Default Isr#s and Proc's

    Is an ISR effectively a Proc in P24 speak?

    i.e. If I have

    Code:
    Isr T1Interrupt
    Dim Idx As Word      '
    Is the Idx variable a local variable and cannot be accessed outside the Isr even if the external variable has the same name.
    JohnB

  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,517
    Thumbs Up
    Received: 319
    Given: 153
    Total Downloaded
    1.99 GB

    0 Not allowed!

    Default Re: Isr#s and Proc's

    No John. It is a standard subroutine that the compiler recognises as an interrupt handler, and so does the Linker.

    However, you can put an Isr handler within a procedure, which I often do. I always put it within the procedure that sets up the interrupt, so that it is always included within the program when it is also enabled.

    If the interrupt is not enabled, the handler does not exist also. For example:

    Code:
    '--------------------------------------------------------------------
    ' Initialise a Timer1 interrupt
    ' Input     : None
    ' Output    : None
    ' Notes     : Also wraps the Interrupt handler within the procedure
    '
    Proc Timer1_Start()
        T1CON = 0                       ' Reset the T1CON SFR
        T1CONbits_TCKPS0 = 0            ' \
        T1CONbits_TCKPS1 = 0            ' / Timer1 Prescaler 1:8
    
        PR1 = cPR1_Value                ' Set the Match value (will roll over and cause an interrupt when this value is reached)
        TMR1 = 0                        ' Reset Timer1 value
        IFS0bits_T1IF = 0               ' Clear the Timer1 interrupt flag
        IPC0bits_T1IP0 = 1              ' \
        IPC0bits_T1IP1 = 1              ' | High Priority Timer1 interrupt
        IPC0bits_T1IP2 = 1              ' /
        T1CONbits_TON = 1               ' Turn on Timer1
        IEC0bits_T1IE = 1               ' Enable the Timer1 interrupt
        Return                           ' Exit before falling into the interrupt handler 
    
    '------------------------------------
    ' Timer1 Interrupt handler
    ' Input     : None
    ' Output    : None
    ' Notes     : None
    '
    ISR_Start T1Interrupt
        Inc Global_wSystemClock
        IFS0bits_T1IF = 0               ' Clear the Timer1 flag
    ISR_End
    EndProc
    Last edited by top204; 23rd February 2017 at 17:34.

  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
    Prolific Poster johngb's Avatar
    Join Date
    Oct 2003
    Posts
    2,171
    Thumbs Up
    Received: 96
    Given: 1
    Total Downloaded
    2.91 GB

    0 Not allowed!

    Default Re: Isr#s and Proc's

    That's neat. I'll implement it that way and just have my variable in the procedure.
    JohnB

  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
    Prolific Poster johngb's Avatar
    Join Date
    Oct 2003
    Posts
    2,171
    Thumbs Up
    Received: 96
    Given: 1
    Total Downloaded
    2.91 GB

    0 Not allowed!

    Default Re: Isr#s and Proc's

    Can I use the Dec Command on an item in an array?

    e.g. Dec Tasks[idx]

    At present start of with 10 in tasks[idx] but after dec it shows contains 19

    (This is loosely part of this thread as it is in the ISR subroutine).
    JohnB

  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
    Fanatical Contributor top204's Avatar
    Join Date
    Feb 2002
    Posts
    3,517
    Thumbs Up
    Received: 319
    Given: 153
    Total Downloaded
    1.99 GB

    0 Not allowed!

    Default Re: Isr#s and Proc's

    The Dec command works with all variable types, and it is essentially, Variable = Variable - 1. Try the program below:

    Code:
        Device = 24FJ64GA002
        Declare Xtal = 32
    '
    ' USART1 declares
    '
        Declare Hserial_Baud = 9600                 ' UART1 baud rate
        Declare HRSOut1_Pin = PORTB.14              ' Select which pin is to be used for TX with USART1
    
        Dim Tasks[10] As Byte = 10, 20, 30 40, 50, 60, 70, 80, 90, 100
        Dim Index As Byte
        Dim Amount As Byte
        
    Main:    
        RPOR7 = 3                                   ' Make Pin RP14 U1TX
        
        For Amount = 1 To 10                        ' Decrement 10 times
            For Index = 0 To 9                      ' The element of the array
                Dec Tasks[Index]                    ' Decrement an element
                HRSOut Dec Tasks[Index], ","        ' Display the element value            
            Next
            HRSOut 13                               ' Next line
            DelayMS 200
        Next
        Stop
    On the serial terminal, the text is:

    9,19,29,39,49,59,69,79,89,99,
    8,18,28,38,48,58,68,78,88,98,
    7,17,27,37,47,57,67,77,87,97,
    6,16,26,36,46,56,66,76,86,96,
    5,15,25,35,45,55,65,75,85,95,
    4,14,24,34,44,54,64,74,84,94,
    3,13,23,33,43,53,63,73,83,93,
    2,12,22,32,42,52,62,72,82,92,
    1,11,21,31,41,51,61,71,81,91,
    0,10,20,30,40,50,60,70,80,90,

    Showing that each element is decremented per loop of Amount.

  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
    Prolific Poster johngb's Avatar
    Join Date
    Oct 2003
    Posts
    2,171
    Thumbs Up
    Received: 96
    Given: 1
    Total Downloaded
    2.91 GB

    0 Not allowed!

    Default Re: Isr#s and Proc's

    Wrong Dec command - I meant the Dec command that decrements a variable.
    The answer seems to be no it doesn't work on an Array item

    This works...

    Code:
    If Tasks[idx + _Timer] > 0 Then
              TmpW = Tasks[idx + _Timer]
              Dec TmpW 
              If TmpW = 0 Then
    This doesnt

    Code:
    If Tasks[idx + _Timer] > 0 Then
              Dec Tasks[idx + _Timer]
              If Tasks[idx + _Timer] = 0 Then
    JohnB

  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
    Fanatical Contributor top204's Avatar
    Join Date
    Feb 2002
    Posts
    3,517
    Thumbs Up
    Received: 319
    Given: 153
    Total Downloaded
    1.99 GB

    0 Not allowed!

    Default Re: Isr#s and Proc's

    An array with an expression as its elements has now been corrected with both Inc and Dec. I used W0 a the result of reading the array, then incremented it, but it got overwritten before it could be placed into the destination array again. Sorry about that John.

    A new installer will be placed on teh forum in a short time.

  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
    Prolific Poster johngb's Avatar
    Join Date
    Oct 2003
    Posts
    2,171
    Thumbs Up
    Received: 96
    Given: 1
    Total Downloaded
    2.91 GB

    0 Not allowed!

    Default Re: Isr#s and Proc's

    We seem to be keeping you busy at the moment.

    Thanks Les for all your help.
    JohnB

  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
    Prolific Poster johngb's Avatar
    Join Date
    Oct 2003
    Posts
    2,171
    Thumbs Up
    Received: 96
    Given: 1
    Total Downloaded
    2.91 GB

    0 Not allowed!

    Default Re: Isr#s and Proc's

    Code:
    • If Tasks[idx + _Timer] > 0 Then Dec Tasks[idx + _Timer] If Tasks[idx + _Timer] = 0 Then
    Now works fine, thanks Les.
    JohnB

  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
    Prolific Poster charliecoultas's Avatar
    Join Date
    Sep 2010
    Posts
    1,397
    Thumbs Up
    Received: 48
    Given: 40
    Total Downloaded
    3.45 GB

    1 Not allowed!

    Default Re: Isr#s and Proc's

    We HAVE to keep Les busy John, otherwise he would start designing with valves and put me out of a job at Bletchley!

    Charlie

  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
    Fanatical Contributor top204's Avatar
    Join Date
    Feb 2002
    Posts
    3,517
    Thumbs Up
    Received: 319
    Given: 153
    Total Downloaded
    1.99 GB

    0 Not allowed!

    Default Re: Isr#s and Proc's

    Oh I wish Charlie. Not to take your job, but to work on real electronics again. LOL

    Bless him, my lovely uncle Tommy is buying me a workshop for our garden, so I can get back into things properly, instead of just using the spare bedroom.

  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.

Thread Information

Users Browsing this Thread

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

     

Similar Threads

  1. Bug in PROC that begin with T
    By GAMBOA in forum Proton Studio
    Replies: 1
    Last Post: 28th December 2018, 17:41
  2. Coming out of an ISR
    By johngb in forum Proton 24
    Replies: 7
    Last Post: 24th November 2017, 07:33
  3. Replies: 6
    Last Post: 9th May 2017, 16:46
  4. How to load an array Proc?
    By normnet in forum Proton 24
    Replies: 6
    Last Post: 11th April 2015, 13:24

Tags for this Thread

Posting Permissions

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