[an error occurred while processing this directive]
[an error occurred while processing this directive]
|
#include
typedef union {
volatile unsigned char byte;
struct {
volatile unsigned char b0:1;
volatile unsigned char b1:1;
volatile unsigned char b2:1;
volatile unsigned char b3:1;
volatile unsigned char b4:1;
volatile unsigned char b5:1;
volatile unsigned char b6:1;
volatile unsigned char b7:1;
} b;
} PORT;
__io PORT PORTB_ @ 0x18;
__io PORT DDRB_ @ 0x17;
__io PORT PORTD_ @ 0x12;
__io PORT DDRD_ @ 0x11;#define PORTB PORTB_.byte
#define PORTD PORTD_.byte
#define D1 PORTD_.b.b2 //кнопка 1
#define D2 PORTD_.b.b3 //кнопка 2
#define sv1 PORTB_.b.b0 //светодиод 1
#define sv2 PORTB_.b.b1 //светодиод 2void init(void){
PORTB=0x00;
DDRB=0xаа;
PORTD=0x00;
DDRD=0x00;
TCCR0=0x00;
TCNT0=0x00;
TCCR1A=0x00;
TCCR1B=0x00;
TCNT1H=0x00;
TCNT1L=0x00;
OCR1H=0x00;
OCR1L=0x00;
GIMSK=0x00;
MCUCR=0x00;
TIMSK=0x00;
ACSR=0x80;
WDTCR=0x00;
}
void keyb(void)
{
if(D1==1){
sv1 = 1;
} else
sv1 = 0;
if(D2==1){
sv2 = 1;
} else
sv2 = 0;
}void main(void)
{
init();
loc_1:
keyb();
goto loc_1;
}
E-mail: info@telesys.ru