打印
[MCU]

简单的430数码管显示程序,有一些问题,求指点

[复制链接]
268|0
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
潮流大家电|  楼主 | 2020-11-10 15:28 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
本来要数码管显示01234567的,但只显示012其余位没有,不知什么原因?????

其中p55和p66是两片74hc595的锁存信号
附程序如下
#include
#define uchar unsigned char
#define uint  unsigned int  
#define WM1   P5OUT |= BIT5
#define WM0   P5OUT &=~BIT5
#define DM1   P6OUT |= BIT6
#define DM0   P6OUT &=~BIT6
uchar Code[16]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,
                0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};
uchar BitCode=0x80;

void InitClock(void)
{
  BCSCTL1=RSEL2+RSEL1+RSEL0;
  DCOCTL =DCO2 +DCO1 +DCO0 ;
  do
  {
    IFG1 &= ~OFIFG;
    for(uint j=0;j<255;j++);
  }
  while((IFG1&OFIFG)!=0);
  BCSCTL2=SELS+SELM1;
}

void Delay_ms (uint ms)
{
   while(ms--)
   {
     for(uint i=0;i<800;i++);
   }
}

void InitPort (void)
{
  
  P4SEL = 0x00;
  P5SEL&=~BIT5;
  P6SEL&=~BIT6;
  P4DIR = 0xFF;
  P5DIR|= BIT5;
  P6DIR|= BIT6;

}

void main (void)
{
  WDTCTL=WDTPW+WDTHOLD;
  InitClock();
  InitPort ();
  P4OUT = 0x00;
  P5OUT&=~BIT5;
  P6OUT&=~BIT6;
  while(1)
  {
    for(uint i=0;i<8;i++)
    {
      P4OUT=Code;
      DM1;
      DM0;
      P4OUT=~BitCode;
      WM1;
      WM0;
      BitCode>>=1;
      if(BitCode==0)
      BitCode=0x80;
      Delay_ms(2);
    }
  }
}

使用特权

评论回复

相关帖子

发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

5

主题

13

帖子

0

粉丝