我正在尝试创建一个程序,以便在PORTA开发板的每一位上使用shift闪存一个LED。当我模拟程序时,输出不是位0-7之间的移位,而是0x01、0x02、ox04、0x10。然后重新开始。有什么原因我不能完全通过8位寄存器吗?任何帮助都将不胜感激。
#define F_CPU 1000000UL
#include <avr/io.h>
#include <util/delay.h>
int main(void)
{
DDRA = 0xFF;
while (1)
{
PORTA = 0x01;
_delay_ms(1000);
for (int count = 0; count < 7; count++)
{
PORTA = 1<<PORTA;
_delay_ms(1000);
}
}
}发布于 2018-08-30 12:30:41
也许你的意思是:
for (int count = 0; count < 8; count++)
{
PORTA = 1<<count;
_delay_ms(1000);
}https://stackoverflow.com/questions/52096913
复制相似问题