51单片机,8*8点阵闪烁问题,点阵滚动时每移动一下就闪烁,不能稳定显示,点阵接口是P0口和74hc595芯片
这是源程序,请大佬看一下,叩谢!!!本人初学单片机。。。如果程序不好,请如何改进啊,,谢谢!#include<reg51.h>#include<intrins.h>typ...
这是源程序,请大佬看一下,叩谢!!!本人初学单片机。。。如果程序不好,请如何改进啊,,谢谢!#include <reg51.h>#include<intrins.h>typedef unsigned char u8; typedef unsigned char u16;unsigned char cnt = 0;sbit SRCLK = P3^6;sbit RCLK = P3^5;sbit SER = P3^4;unsigned char code ledlie[] ={ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x82,0xFE,0xFE,0x82,0x00,0x00, 0x70,0xF8,0xFC,0x7E,0x7E,0xFC,0xF8,0x70, 0x00,0xFC,0xFE,0x02,0x02,0xFE,0xFC,0x00, 0x20,0x44,0x22,0x02,0x02,0x22,0x44,0x20, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};u8 ledwei[] ={ 0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe};void Hc595SendByte(u8 dat){ u8 i; SRCLK=0; RCLK=0; for(i=0;i<8;++i) { SER = dat >> 7; dat <<= 1; SRCLK = 1; _nop_(); _nop_(); SRCLK = 0; } RCLK = 1; _nop_(); _nop_(); RCLK = 0;}void delay(unsigned int xms) { unsigned int x,y; for(x=xms;x>0;x--) for(y=110;y>0;y--);}void main(){ unsigned int m = 0; unsigned int i = 0; unsigned int j = 0; P0 = 0xFF; while(1) { for(i=0;i<=39;++i) { for(j=0;j<8;++j) { P0=ledwei[j]; Hc595SendByte(ledlie[i+j]); delay(1); Hc595SendByte(0x00); } delay(250); } } }
展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询