用MSP430驱动74HC595,下面是主程序,P2.0是串行数据输入,P2.1是RCK,P2.2是SCK,假设的串行输入为01010101,为什么在HC595的并行输出几个脚上测不到电压呢,是串行数据没进去还是并行数据没出来呢?
void main()
{
WDTCTL=WDTPW+WDTHOLD;
Clock_Init();
unsigned int i = 8;
P2SEL &= ~ (BIT0+BIT1+BIT2);
P2DIR |= BIT0+BIT1+BIT2;
P2OUT &= ~(BIT1+BIT2);
for (i=0;i<8;i++)
{
P2OUT &= ~BIT2;
if((DATA & BIT0) == BIT0)
P2OUT |= BIT0;
else
P2OUT &= ~BIT0;
DATA >>= 1;
P2OUT |= BIT2; // 移位寄存器上升沿脉冲
}
P2OUT &= ~ BIT1; //存储上升沿脉冲
_NOP();
P2OUT |= BIT1;
}
|