Loading ...
Sorry, an error occurred while loading the content.

Re: [jallist] Interups

Expand Messages
  • Vasile Surducan
    ... What if the ISR is consuming 90% of the processor time and the main the rest ? Do you think will not work the same ? There is no other rule in splitting
    Message 1 of 5 , Jul 1 12:46 AM
    • 0 Attachment
      On Thu, 1 Jul 2004, Eur van Andel wrote:

      > On Wed, 30 Jun 2004 16:50:44 +0000, "Malcolm Crabbe" <malcrabbe@...>
      > wrote:
      >
      > >I have been following the thread regarding the use of interups and simply
      > >opened up and pasted in the code used in the original mail as I too would
      > >like to understand the use of interups to sequence some LEDs whilst also
      > >monitoring a PWM signal from an RC receiver used for model aircraft.
      > Interrupts are difficult.
      >
      > An ISR must be seen as a small simple routine that either:
      >
      > acts quickly upon sudden external events


      What if the ISR is consuming 90% of the processor time and the main the
      rest ? Do you think will not work the same ?
      There is no other rule in splitting the time between main and isr than
      "event logic". If the user logic is good (not like mine in previous post)
      than even 50% in ISR and 50% in main is a valid option. Everything depends
      on time requirements.


      >
      > or
      >
      > routinely handles an internal event which must happen every xxx (milli)
      > seconds.
      >
      > In your case I'd blink the LEDS with the ISR. Then your main code can wait for
      > the RC signal to go up & down.
      >
      > >include 16f84_4
      > >include jpic
      > >include jlib
      > >include interval
      > pitfall number one: then interval lib uses interrupts. You can't use any other
      > interrupts then.
      >
      > >
      > >pin_a0_direction = output
      > >port_b_direction = all_input
      > >
      > >var byte oncount = 255
      > >var byte offcount = 0
      > >
      > >init_interval_100uS(1)
      > >
      > >forever loop
      > >
      > >for oncount loop
      > >pin_a0 = high
      > >-- delay_1us(1)
      > >next_interval
      > >end loop
      > >
      > >for offcount loop
      > >pin_a0 = low
      > >-- delay_1us(1)
      > >next_interval
      > >end loop
      > This code generates an PWM sequence. It does not monitor one.
      >
      >
      > >
      > >oncount = oncount + 1
      > >offcount = 255 - oncount
      > >
      > >end loop
      > >
      > >However when I try and assemble the program JAL reports an error:
      > >
      > >jal 0.4.60 (GCC 3.2)
      > >[Error] (interval.jal) [line 12 char 1] unknown identifier
      > >init_interval_100uS
      > >
      > >Can anyone shed some light on whats wrong.
      > Read interval.jal for the precise spelling of init_interval_100uS
      > --
      > Ir. E.E. van Andel, Fine Wire Heat Exchangers, Fiwihex B.V. www.fiwihex.com
      > Wierdensestraat 74, NL-7604 BK Almelo, The Netherlands eur@...
      > phone +31-546-491106 fax +31-546-491107 mobile +31-653-286573
      >
      >
      >
      >
      > Yahoo! Groups Links
      >
      >
      >
      >
      >
    • Eur van Andel
      On Thu, 1 Jul 2004 10:46:10 +0300 (EEST), Vasile Surducan ... Sure. But beware of the following: Don t use * / ^ & % in ISR. Don t call subroutines (especially
      Message 2 of 5 , Jul 1 1:31 AM
      • 0 Attachment
        On Thu, 1 Jul 2004 10:46:10 +0300 (EEST), Vasile Surducan
        <vasile@...-cj.ro> wrote:

        >> Interrupts are difficult.
        >> An ISR must be seen as a small simple routine that either:
        >> acts quickly upon sudden external events
        >> or
        >> routinely handles an internal event which must happen every xxx (milli)
        >> seconds.
        >
        > What if the ISR is consuming 90% of the processor time and the main the
        >rest ? Do you think will not work the same ?
        >There is no other rule in splitting the time between main and isr than
        >"event logic". If the user logic is good (not like mine in previous post)
        >than even 50% in ISR and 50% in main is a valid option. Everything depends
        >on time requirements.
        Sure. But beware of the following:

        Don't use * / ^ & % in ISR.

        Don't call subroutines (especially that call others) in ISR, this adds too much
        to the stack.

        So the code in the ISR can't be too large and it is best to keep it all in
        assembler unless you *know* what the compiler output will be.

        In this case the program must wait for an PWM signal in ms. A LED blinking ISR
        does not need to be more than 10 instructions, 20 with overhead. That is 4uS @
        20 MHz.

        --
        Ir. E.E. van Andel, Fine Wire Heat Exchangers, Fiwihex B.V. www.fiwihex.com
        Wierdensestraat 74, NL-7604 BK Almelo, The Netherlands eur@...
        phone +31-546-491106 fax +31-546-491107 mobile +31-653-286573
      Your message has been successfully submitted and would be delivered to recipients shortly.