#include<reg52.h> /***********定义数据类型*************/ typedef unsigned char uint8; typedef signed char int8; typedef unsigned short uint16; typedef signed short int16; typedef unsigned int int32; typedef signed int uint32; typedef float fl32; typedef double db64; /*************************************/ sbit P2_7=P2^7; sbit P2_6=P2^6; sbit P2_5=P2^5; /************************************/ #define RCK_H() (P2_7=1) #define RCK_L() (P2_7=0) #define SI_H() (P2_6=1) #define SI_L() (P2_6=0) #define SCK_H() (P2_5=1) #define SCK_L() (P2_5=0) /***********************************/ const uint8 number[10]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90}; /*****************************子程序***************************************/ void S74595(uint8 dat) { uint8 i; RCK_L(); for(i=0;i<8;i++) { SCK_L(); if((dat & 0x80)!=0) {SI_H();} else {SI_L();} dat<<=1; SCK_H(); } RCK_H(); } /**************************************************/ void Timer1(void) interrupt 3 { static uint8 count,i; count++; if(count==16) { count=0; S74595(number); i++; if(i==10) {i=0;} } } /************************************************************************/ main() { EA=1; ET1=1; TH1=0x0B; TL1=0xDC; TMOD=0x0100; TR1=1; while(1); } 数码管怎么变化的很快.按程序应该1s才变化一次 难道代码错了 哪位大侠能否帮我解释一下
|