SuperTao 发表于 2012-12-28 09:15:28

方便的输入输出设置(标题不合格,封锁ID)

sfrb PIND=0x10;
sfrb DDRD=0x11;
sfrb PORTD=0x12;
sfrb PINC=0x13;
sfrb DDRC=0x14;
sfrb PORTC=0x15;
sfrb PINB=0x16;
sfrb DDRB=0x17;
sfrb PORTB=0x18;
sfrb PINA=0x19;
sfrb DDRA=0x1a;
sfrb PORTA=0x1b;

#define bit1(a,b) (a|=1<<b)
void main(void)
{
bit1(PORTA,0);
}
小弟初学AVR,有很多不懂,请个位不要见怪。
我想通过PORTA的地址,算出DDRA的地址,并进行赋值。
比如#define bit1(a,b) (a-1|=1<<b,a|=1<<b)
但是报错了,不知道怎么写,所以来问问论坛的高手。

armok 发表于 2012-12-28 09:21:18

xiaodao35 发表于 2012-12-28 09:22:10

#define                SBI(Y,x) Y |=(1<<x)
#define                CBI(Y,x) Y &=~(1<<x)
页: [1]
查看完整版本: 方便的输入输出设置(标题不合格,封锁ID)