SV: [Icc-avr] Global Interrupts
Bengt Ragnemalm
benra at imt.liu.se
Tue Jan 8 23:42:34 PST 2008
I have a lot of similar applications. I think I use the same approach as you
although I do not think I fully understand your system. I have a timer that
is used a sample rate timer.
The application runs and samples some channels and other stuff.
Then it calls a function that sets a flag that means that all is done and
puts the CPU into sleep.
The sample rate timer will wake the CPU up and the interrupt routine checks
the flag. If the flag is not set it means that the sample rate timer is to
fast or that the program have been delayed for some reason. This approach
should be very safe to use I think but there are several other methods.
/Bengt
> -----Ursprungligt meddelande-----
> Från: icc-avr-bounces at imagecraft.com [mailto:icc-avr-
> bounces at imagecraft.com] För Andrew
> Skickat: den 8 januari 2008 23:51
> Till: Johannes Assenbaum; Discussion list for ICCAVR and ICCtiny Users.
> You do NOT needtosubscribeto icc-announce if you are a member of this.
> Ämne: Re: [Icc-avr] Global Interrupts
>
>
> Kinda basically is it safe to do it is the question. although the ADC is
> clocked at 2MHz and i am reading only 4 channels 10 times i am worried
> about
> the timer interrupt srewing the ADC reading process. So i thought i would
> be
> best if i turn off all interrupts do my reads and turn them back on.
>
> The timer is used as an overflow timer as in i do something each time it
> overflows (on it's interrupt) although it is used to check the ADC values
> every 500ms (which would be 5 interrupt counts), time out for a usb buffer
> collect and de-bouncer.
>
> is it safer to reset the count value after the enable?
>
> Andy
>
>
>
>
> --------------------------------------------------
> From: "Johannes Assenbaum" <jassenbaum at htp-tel.de>
> Sent: Tuesday, January 08, 2008 10:38 PM
> To: <icc-avr at imagecraft.com>
> Subject: Re: [Icc-avr] Global Interrupts
>
> > If back ground timer is fully hardware, then tick will be ok, only
> > interrupt handling may be a bit later than asap.
> >
> > If back ground timer is with any software, then timing may miss some
> timer
> > interrupts while polling ADC and so may go wrong a bit.
> >
> > Is this what you wanted to know?
> >
> > Best regards,
> > Johannes
> >
> >
> >> Hi,
> >
> >> i have an ADC connect to my system using SPI and in the back ground a
> >> tick timer
> >> overflow interrupt (100ms). when i call my read ADC function to avoid
> any
> >> interrupts messing things i was going to do the follwing: -
> >
> >> CLI(); // Disable all interrupts
> >> Get 4 Channels of results
> >
> >> SEI(); // Re-enable interrupts
> >
> >
> >
> >> My question is will doing that screw the timer up or will it carry on
> >> from where it
> >> left off after i re-enable the interrupts.
> >
> >
> >
> >> Andy
> >
> >> ----- Original Message -----
> >> From: Paul Mateer
> >> To: Discussion list for ICCAVR and ICCtiny Users. You do NOT need
> >> tosubscribe to
> >> icc-announce if you are a member of this.
> >> Sent: Tuesday, January 08, 2008 8:13 PM
> >> Subject: Re: [Icc-avr] Software Delay
> >
> >
> >> ...then I test dbc_kpd for my keypress.
> >
> >
> >
> >> On Jan 8, 2008 11:31 AM, Paul Mateer <paul.aa9gg at gmail.com> wrote:
> >
> >> Keybounce "delays" can get you into trouble sometimes. I use this
> >> code placed
> >> into an timer-overflow interrupt:
> >
> >> #define KEYPADS PINH
> >> unsigned int dbc_j, dbc_i, dbc_idx, dbc_kpd,State[10]; //
> >> key-debounce stuff
> >
> >> interrupt routine()
> >> {
> >> // begin new keypad debounce routine
> >> State[dbc_idx] = KEYPADS & 0xFF;
> >> ++dbc_idx;
> >> dbc_j = 0xff;
> >> for(dbc_i=0; dbc_i < 4; dbc_i++) dbc_j = dbc_j & State[dbc_i];
> >> dbc_kpd = dbc_j;
> >
> >> if(dbc_idx >= 5) dbc_idx = 0;
> >
> >> }
> >
> >
> >> On Jan 8, 2008 10:45 AM, Daub, Stephan < stephan.daub at sap.com>
> wrote:
> >
> >> Hi andy,
> >
> >> To determine the length of the loop you simpy add the inner loop
> >> maschine
> >> cycles plus the entry cycles plus for/while time. Once you have
> >> calc this you
> >> multiply this with your systemclock and youre done.
> >
> >> Best, stephan
> >
> >
> >> -----Original Message-----
> >> From: icc-avr-bounces at imagecraft.com <
> >> icc-avr-bounces at imagecraft.com>
> >> To: Discussion list for ICCAVR and ICCtiny Users. You do NOT
> >> needtosubscribeto icc-announce if you are a member of this. <
> >> icc-avr at imagecraft.com >
> >> Sent: Tue Jan 08 17:18:10 2008
> >> Subject: [Icc-avr] Software Delay
> >
> >> Hi,
> >
> >> I need a good software time delay that sit's in an interrupt
> >> handler.
> >> Basically i need it to de-bounce a pin (INT1). and i cannot use a
> >> timer as
> >> the timer interrupts are disabled at this point in the code.
> >
> >> I was thinking of using : -
> >
> >> #pragma interrupt_handler int1_isr:iv_INT1
> >> void int1_isr(void)
> >> {
> >
> >> delay_2();
> >
> >> }
> >
> >
> >
> >>
> >> //---------------------------------------------------------------------
> ------
> >> --
> >> //
> >> // Function name : Delay_2
> >> //
> >> // Returns : None
> >> //
> >> // Parameters : None
> >> //
> >> // Purpose : De-Bouce delay
> >> //
> >>
> >> //---------------------------------------------------------------------
> ------
> >> --
> >> void delay_2 (void)
> >> {
> >
> >> for (loop_int = 0; loop_int < 100; loop_int++)
> >> {
> >> NOP();
> >> }
> >
> >> loop_int = 0x00;
> >
> >> }
> >
> >
> >
> >> Only probem is that i have no clue how long this delay is? ( i am
> >> running the
> >> main clock at 8Mhz)
> >
> >
> >
> >> Does anydy have a better software delay function.
> >
> >
> >
> >> Andy
> >
> >
> >
> >> _______________________________________________
> >> Icc-avr mailing list
> >> Icc-avr at imagecraft.com
> >> http://dragonsgate.net/mailman/listinfo/icc-avr
> >
> >
> >
> >
> >
> >> --
> >> Paul Mateer, AA9GG
> >> Elan Engineering Corp.
> >> www.elanengr.com
> >
> >
> >
> >> --
> >> Paul Mateer, AA9GG
> >> Elan Engineering Corp.
> >> www.elanengr.com
> >
> >
> >> -----------------------------------------------------------------------
> -------
> >
> >
> >> _______________________________________________
> >> Icc-avr mailing list
> >> Icc-avr at imagecraft.com
> >> http://dragonsgate.net/mailman/listinfo/icc-avr
> >
> >
> >
> > _______________________________________________
> > Icc-avr mailing list
> > Icc-avr at imagecraft.com
> > http://dragonsgate.net/mailman/listinfo/icc-avr
> >
>
> _______________________________________________
> Icc-avr mailing list
> Icc-avr at imagecraft.com
> http://dragonsgate.net/mailman/listinfo/icc-avr
More information about the Icc-avr
mailing list