Atmega, időzítés

Auth Gábor auth.gabor at enaplo.hu
Sun Apr 23 11:30:14 CEST 2006


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