Re: Atmega, időzítés
Bali Zoltan
eltexto at freemail.hu
Sun Apr 23 13:57:56 CEST 2006
Szia !
Túl hoszzú az 1204-es előosztás 1MHz-en.
Szerintem nem vártad meg a ~65 másodpercet,
ami után lesz túlcsordulás, azaz egy increment.
Vedd rövidebre az előosztót pl. 8-ra, ~0.5 sec-enként
növel, ha jól számoltam.
Üdv Zoli
----- Original Message -----
From: "Auth Gábor" <auth.gabor at enaplo.hu>
To: <elektro at tesla.hu>
Sent: Sunday, April 23, 2006 11:30
Subject: Atmega, időzítés
> Halihó!
>
> Próblkozom az alábbi programmal, amely valahogy nem akarja az időzítés
> lejártakor a megszakítást végrehajtani, illetve egyátalán számolni (?):
> ===
> #include <avr/io.h>
> #include <avr/interrupt.h>
> #include <avr/signal.h>
> #include <inttypes.h>
> #define F_CPU 1000000UL // 1 MHz
> #include <util/delay.h>
>
> #define set_bit(port,mask) ((port) |= (_BV(mask)))
> #define clr_bit(port,mask) ((port) &=~(_BV(mask)))
> #define inv_bit(port,mask) ((port) ^= (_BV(mask)))
>
> char count=10;
>
> INTERRUPT(SIG_OVERFLOW1)
> {
> TCNT1=0x0010;
> count++;
> }
>
> int main(void)
> {
> DDRB=0xF9;
> DDRD=0xFF;
> DDRC=0xFF;
> PORTC=PINB;
> PORTD=count;
>
> TCCR1B=0x05;
> clr_bit(TIMSK,TOIE1);
> TCNT1=0x0010;
> set_bit(TIMSK,TOIE1);
> sei();
>
> while (1)
> {
> _delay_ms(25);
> inv_bit(PORTB,0);
> PORTC=PINB;
> PORTD=count;
> }
> return(0);
> }
> ===
> A PB0 villog, a PCx megegyezik a PBx bementeten lévő kapcsolók
> állásával. Csak nem számol... :)
> Milyen triviális dolgot rontok el?
> --
> http://www.enaplo.hu - Iskolai Információs Rendszer
> Auth Gábor -=- FreeBSD 5.4 -=- http://bsd.lap.hu
> +36-70/9400-341 -=- ICQ: 49179141 -=- Skype: authgabor
More information about the Elektro
mailing list