Interrupt and SHout problem - Page 2


+ Reply to Thread
Page 2 of 2 FirstFirst 12
Results 16 to 19 of 19

Thread: Interrupt and SHout problem24 days old

  1. #16
    Junior Member run75's Avatar
    Join Date
    Jan 2020
    Posts
    8
    Thumbs Up
    Received: 0
    Given: 0
    Total Downloaded
    0

    0 Not allowed!

    Default Re: Interrupt and SHout problem

    I understand that the interruption is not included a lot of things, but I don't see how it will work then.
    If there is a schedule in the Main Loop that is longer than an IR signal, it may not read the IR signal when it returns from the interrupt. That's why I lost the signal. Or am I seeing it badly?
    Just for example:



    Isr_Handler:
    Context Save
    'RA2/INT---
    If IntF =1 Then
    If IRworkF=1 Then GoTo IsrExit 'If my IR work flag =1, then exit
    IRworkF=1 'set a flag that this happened
    IsrExit:
    IntF=0
    EndIf
    Context Restore
    '---------------------------------------

    Proc IRread()
    Puffer=PulsIn IRport,Low 'Read start signal

    If Puffer<50 Then GoTo IsrExit 'check this
    If Puffer>90 Then GoTo IsrExit

    i=0
    Repeat 'If start signal is good
    pulseLen[i]= PulsIn IRport,2 'Store 32 pulse
    Inc i
    Until i >=31

    ...

    IRworkF=0 'clear my IR work flag

    EndProc
    '------------------------------

    MAIN:
    do if IRworkF=1 then
    IRread()
    endif
    Led=1 delay
    MS 1000
    led=0
    delayMS 1000
    loop



    If the interrupt is not triggered before "if IRworkF = 1 then" ... then 2ms will elapse and the signal will disappear.
    No?
    Last edited by run75; 6th February 2020 at 17:03.

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
    Junior Member Dave Purola's Avatar
    Join Date
    Jul 2004
    Posts
    73
    Thumbs Up
    Received: 5
    Given: 0
    Total Downloaded
    223.72 MB

    0 Not allowed!

    Default Re: Interrupt and SHout problem

    In your "Proc IRread()" you are going to the "IsrExit" which has NOTHING to do with the "Proc IRread()". The Isr_Handler: has already finished up and has "Context Restored" already. You haven't even finished the procedure.

  • 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.

  • #18
    Senior Member tumbleweed's Avatar
    Join Date
    May 2011
    Posts
    498
    Thumbs Up
    Received: 59
    Given: 0
    Total Downloaded
    408.14 MB

    0 Not allowed!

    Default Re: Interrupt and SHout problem

    If there is a schedule in the Main Loop that is longer than an IR signal, it may not read the IR signal when it returns from the interrupt
    That is true.

    Measuring the pulse width could well be a case of something that has to be done in the ISR, but the code I was commenting on had a 'Print' statement in the ISR for the timer code, and useless "set flag and do nothing" code in the next example.

    The general rule is to try and do as little as possible in the ISR, but you DO have to actually do SOMETHING or else there's no reason to use interrupts in the first place. Having loops that wait in the ISR is usually a sign that things are structured poorly.

    If the timer intr is enabled while trying to measure pulses then your initial pulse width may be incorrect, and by using PulseIn statements in the ISR to measure 32 pulses means that it'll hang in the ISR until 32 pulses are measured. If that takes longer than the 500ms timer then the timer count will be off. All of this may be acceptable to you.

    The code keeps changing from post to post so it's hard to comment in any more detail.

  • 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
    Junior Member run75's Avatar
    Join Date
    Jan 2020
    Posts
    8
    Thumbs Up
    Received: 0
    Given: 0
    Total Downloaded
    0

    0 Not allowed!

    Default Re: Interrupt and SHout problem

    Thanks, I rewrote the code based on what you advised and so the interrupt works and the SHOUT doesn't freeze.
    I just thought that what I did with the extra flag bit (IRwork) was not elegant.
    I guess the pros don't do it that way.

  • 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. SHOUT and PIC16F18877 - problem
      By kuhrig in forum Proton Plus Compiler v3
      Replies: 1
      Last Post: 18th March 2019, 14:55
    2. [SOLVED !] Interrupt Problem
      By roger in forum Proton 24
      Replies: 6
      Last Post: 3rd November 2013, 22:14
    3. [SOLVED !] Problem with SHout command
      By geoff_c in forum Proton Plus Compiler v3
      Replies: 2
      Last Post: 1st December 2012, 21:01
    4. [SOLVED !] Interrupt problem.
      By ~ Sy ~ in forum The Lounge
      Replies: 8
      Last Post: 3rd September 2009, 22:13
    5. SHIN-SHOUT problem
      By abdelrazzac10 in forum Proton Plus Compiler v3
      Replies: 4
      Last Post: 28th May 2007, 15:09

    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