我仿照51写的驱动74ls164 拓展IO口的程序 求大神指教啊

2019-07-15 16:47发布

#include "msp430g2553.h"
#define uint unsigned int
#define uchar unsigned char
//--------------函数声明------------------
// 延时函数
//P2.0 作为时钟源 P2.3作为数据端
void delay(void)
{
  unsigned int i,j;
for(i=0;i<1000;i++)
{
   for(j = 0;j < 500;j++);
}
}
// 主函数
void main(void)
{
  P2DIR|=0xff;
  P2OUT|=0x09;
unsigned char i;
  P2OUT&= 0x00;
for(i = 0;i < 8;i++)   //
{
    P2OUT= (0x08 << i);    // 数据串行输出,一次移动一位
    P2OUT|= BIT0;     //  数据在上升沿期间输出
    P2OUT&=~BIT0;     //
    delay();
}
while(1)
{
}
}

友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。