帮忙看看51单片机这个程序是哪点的问题
本来是想在led灯上显示一个汉字,结果调试出来灯全在闪烁,代码和实验电路都检查了也不知道是哪点出来问题,麻烦哪位大侠看看#include"reg51.h"#include...
本来是想在led灯上显示一个汉字,结果调试出来灯全在闪烁,代码和实验电路都检查了也不知道是哪点出来问题,麻烦哪位大侠看看#include "reg51.h"#include"intrins.h"typedef unsigned char u8;typedef unsigned char u16;sbit SRCLK=P3^6;sbit RCLK=P3^5;sbit SER=P3^4; u8 code ledwei1[]= { 0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80 }; u8 code ledduan1[]= { /*-- 文字: 普 --*//*-- 宋体12; 此字体下对应的点阵为:宽x高=16x16 --*/0x40,0x44,0x54,0x64,0x45,0x7E,0x44,0x44,0x44,0x7E,0x45,0x64,0x54,0x44,0x40,0x00,0x00,0x00,0x00,0xFF,0x49,0x49,0x49,0x49,0x49,0x49,0x49,0xFF,0x00,0x00,0x00,0x00}; void delay(u16 i ) { while(i--); } void Hc595sendByte(u8 dat1,u8 dat2,u8 dat3,u8 dat4) { u8 a ; SRCLK=1; RCLK=1; for(a=0;a<8;a++) //传递四个参数分别移位四次在移位寄存器当中去 { SER =dat1>>7; dat1<<=1; SRCLK=0; _nop_(); _nop_(); SRCLK=1; } for(a=0;a<8;a++) { SER =dat2>>7; dat2<<=1; SRCLK=0; _nop_(); _nop_(); SRCLK=1; } for(a=0;a<8;a++) { SER =dat3>>7; dat3<<=1; SRCLK=0; _nop_(); _nop_(); SRCLK=1; } for(a=0;a<8;a++) { SER =dat4>>7; dat4<<=1; SRCLK=0; _nop_(); _nop_(); SRCLK=1; } RCLK=0; _nop_(); _nop_(); RCLK=1; } void main() { u8 i ; while(1) { for(i=0;i<16;i++) { Hc595sendByte(~ledwei1[i+16],~ledwei1[i],ledduan1[16+i],ledduan1[i]); delay(10); } } }
展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询