Re: Atmega, időzítés

Bali Zoltan eltexto at freemail.hu
Sun Apr 23 18:02:54 CEST 2006


Érdekes nálam csak az INTERRUPTdefinició miatt
nem futott, ezt kicseréltem ISR(vagy SIGNAL)-ra
és itt villogtak a próbapanelen a PORTD-n levő ledek.
Ja, optimalizáció nélkül próbáltam.

======================
#include <avr/io.h>
#include <avr/signal.h>
#include <avr/interrupt.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;

SIGNAL(SIG_OVERFLOW1)
{
 TCNT1=0x0010;
 count++;
}

int main(void)
{
  DDRB=0xF9;
  DDRD=0xFF;
  DDRC=0xFF;
  PORTC=PINB;
  PORTD=count;

  TCCR1B=0x02;
  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);
}
=================

Üdv  Zoli

----- Original Message -----
From: "Auth Gábor" <auth.gabor at enaplo.hu>
To: <elektro at tesla.hu>
Sent: Sunday, April 23, 2006 17:45
Subject: Re: Atmega, időzítés


> Halihó!
>
> Bali Zoltan ezt írta:
> > ISR(SIG_OVERFLOW1)
>
>   A megoldás:
> volatile static char counter=0x55;
> --
> 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