[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] OVF3 Causes Reset?
From: |
Kevin Neff |
Subject: |
Re: [avr-gcc-list] OVF3 Causes Reset? |
Date: |
Mon, 17 Jan 2005 17:45:12 -0600 (CST) |
I guess I got carried away with preprocessor macros... b0 == ~(B0)
On Mon, 17 Jan 2005, James Washer wrote:
> You sure you didn't want the LED off code to read
>
> PORTF = PINF & (~B0)
>
> - jim
>
> On Mon, 17 Jan 2005 14:26:58 -0600 (CST)
> Kevin Neff <address@hidden> wrote:
>
> >
> > I want a timer to interrupt my program periodically. Below is the code
> > for the interrupt hadler and the code that initilizes the timer.
> >
> > To debug this code I am using an LED. After a hard reset, the LED stays
> > on for 8 seconds. It is turned off at the end of the configuration
> > function and stays off until the interrupt trips (~15 sec), at which
> > point the LED turns on for 8 seconds. My interpretation is that the
> > configuration function is called again, which is only possible if the
> > MCU is reset.
> >
> > Any ideas on how to fix this?
> >
> >
> > ----------
> >
> >
> >
> > void configure_timer()
> > {
> >
> > // LED on
> > DDRF = B0;
> > PORTF = B0;
> > delay( 8000 );
> >
> >
> > // write high byte first, writing the low byte latches data
> > TCNT3H = TIME_SLICE_LEN_H;
> > TCNT3L = TIME_SLICE_LEN_L;
> >
> >
> > // Enable timer interrupt.
> > TIMSK = 0;
> > ETIMSK = B2;
> >
> >
> > // Configure Timer/Counter #3 for normal mode. The timer increments
> > // and the counter is not cleared, it just overflows at 0xFFFF and
> > // continues at 0x0000. TOV3 is set when TCCR3A = TCCR3B = 0.
> > //
> > // To configure the timer in normal mode, WGMn3..0 must be set to zero.
> > // WGMn3 and WGMn2 can be found in bits 4 and 3 of TCCRnB. WGMn1 and
> > // WGMn1 can be found in bits 1 and 0 of TCCRnA.
> > TCCR3A = 0;
> > TCCR3B = 0;
> >
> > // Configure clock source for timer. The clock source can be set using
> > // CS2..0, which can be found as bits 2, 1, and 0 of TCCRnB.
> > //
> > // Timer is on after this operation is executed.
> > TCCR3B |= B2 | B0;
> >
> >
> > // enable global interrupts
> > sei();
> >
> > // LED off
> >
> > PORTF = 0;
> > delay( 1000 );
> > }
> >
> >
> >
> >
> > extern volatile uint8_t TIME_SLICE;
> >
> >
> > SIGNAL( SIG_OVERFLOW3 )
> > {
> > // LED on
> > PORTF = PINF | B0;
> >
> >
> > // write high byte first, writing the low byte latches data
> > TCNT3H = TIME_SLICE_LEN_H;
> > TCNT3L = TIME_SLICE_LEN_L;
> >
> >
> > if( TIME_SLICE == SECTION1 )
> > TIME_SLICE = SECTION2;
> >
> >
> > else if( TIME_SLICE == SECTION2 )
> > TIME_SLICE = SECTION3;
> >
> >
> > else if( TIME_SLICE == SECTION3 )
> > TIME_SLICE = SECTION1;
> >
> > // LED off
> > PORTF = PINF & b0;
> > }
> >
> >
> >
> >
> > _______________________________________________
> > avr-gcc-list mailing list
> > address@hidden
> > http://www.avr1.org/mailman/listinfo/avr-gcc-list
> >
>
> _______________________________________________
> avr-gcc-list mailing list
> address@hidden
> http://www.avr1.org/mailman/listinfo/avr-gcc-list
>
>