[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] Help with interupt (fwd)
From: |
Michael Hadianto |
Subject: |
Re: [avr-gcc-list] Help with interupt (fwd) |
Date: |
Mon, 28 Apr 2003 13:38:39 +0700 (JAVT) |
thanks for your help, yes my interupt vector is reseting my program, the
mistake is very simple, on TCCR1B i set value of 0x01, at it reset my
program all the time, and i make slight mistake on init.
thanks
> Michael,
>
> one thing you would want to look at is the interrupt vectors.
> Seems your timer interrupt points to reset location!?!?
> -uwe
>
> ----- Original Message -----
> From: "Michael Hadianto" <address@hidden>
> To: <address@hidden>
> Sent: Friday, April 25, 2003 12:05 PM
> Subject: [avr-gcc-list] Help with interupt
>
>
> > Hi all,
> >
> > I have problem using interupt, i using avrgcc function SIGNAL
> > (SIG_OVERFLOW0)
> > but i have problem using it. I'am trying to use the function as time.
> > this is my program :
> >
> >
> > SIGNAL (SIG_OVERFLOW0)
> > {
> > if (0x0000 == --time.t_count)
> > {
> > if ( 60 == ++time.sec )
> > {
> > if ( 60 == ++time.min )
> > {
> > if ( 24 == ++time.hour )
> > {
> > time.hour = 0x00;
> > }
> > time.min = 0x00;
> > }
> > time.sec = 0x00;
> > }
> >
> > time.t_count = 27;
> > // Testing
> > if (time.sec % 2)
> > CLRBIT(PORTC,(LED3));
> > else
> > SETBIT(PORTC,(LED3));
> > }
> > }
> >
> >
> > this program works perfectly, and my led is blinking !
> > but in my main program won't start at all !, it keeps looping
> > in the first line. Here my init and i'm using AT90S8535 and
> > using clock 7.372 Mhz :
> >
> >
> > void Setup(void)
> > {
> > // definition of PWM, Ports, UART and Real-Time-Clock
> > TCCR1A = 0xA1; // define timer1 as 8-bit PWM
> > TIFR = 0x04; // clear counter1 overflow flag
> > TIMSK = 0x04; // enable counter1 overflow interrupt
> > TCNT1 = 0x00; // set counter1 to zero
> > TCCR1B = 0x00; // PWM disabLED
> >
> >
> > TCCR0 = 0x05; // Timer0 enabled, divide by 1024
> > sbi(TIMSK, 0); // Enable TCNT0 TOF interrupt
> >
> > PORTA = 0x00; //prepare port A as analog input
> > DDRA = 0x00; // no pull ups
> >
> > PORTC = 0x1F; // Prepare Port C0-C4 as input and C5-C7
> > DDRC = 0xE0; // as output (LED)
> >
> > PORTB = 0x03; // prepare port B0-B1 as ouput (LED)
> > DDRB = 0x03;
> >
> >
> > PORTD = 0xFF; // Turn on internal pull-ups for PORTD
> >
> > ADCSR=0x86; // Single A/D conversion, fCK/64
> >
> > CHARGE_STATUS = 0x00;
> >
> > time.sec = 0x00;
> > time.min = 0x00;
> > time.hour = 0x00;
> > time.t_count = 27;
> >
> > UART_CONTROL_REG = 0x08;
> > UBRR = 0x03;
> > sei(); // global interrupt enable
> > }
> >
> > and this in my main program (not all)
> >
> > int main(void)
> > {
> > Setup();
> > putstr("SMART BATTERY CHARGER NiMh");
> > for (;;)
> > {
> > SETBIT(CHARGE_STATUS,FAST);
> > TERMINATION = 0x00;
> > SETBIT(PORTB,(LED0+LED1+LED2));// Turn all LEDs off
> > SETBIT(PORTC,(LED3+LED4));
> > while ((PINC & (1<<PC4))); // Wait until start pushed
> > while (!(CHKBIT(CHARGE_STATUS,ERROR)))
> > {
> > if ((CHKBIT(CHARGE_STATUS,FAST)) &&
> > (!(CHKBIT(CHARGE_STATUS,ERROR))))
> > {
> > CLRBIT(PORTB,LED2);
> > TERMINATION = 0x00;
> > CHARGE_STATUS = 0x00;
> > FAST_charge();
> > SETBIT(CHARGE_STATUS,TRICKLE);
> > CLRBIT(CHARGE_STATUS,ERROR);
> > putstr("out");
> > }
> >
> >
> > when i activated the SEI(); my program won't start at all ? when i pressed
> > the start button (PORTC4) the program is looping up again so it give me
> > SMART BATTERY CHARGER NiMh massage again and again as long i pressed
> > the start button ?
> >
> > but when i disabled the SEI(); my program work just fine, it works normal
> > !
> > only the time is not shown/work ? is my mistake at init ? I'm using
> > AVRGCC 3.2, or anyone can give me small function counting time using timer
> > overflow only, without using any interupt ?
> >
> > Can anyone help me ?
> >
> > Thanks....
> >
> >
> >
> > _______________________________________________
> > avr-gcc-list mailing list
> > address@hidden
> > http://www.avr1.org/mailman/listinfo/avr-gcc-list
>
Mike "Ob3lix" hadianto
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: [avr-gcc-list] Help with interupt (fwd),
Michael Hadianto <=