欢迎来到天天文库
浏览记录
ID:32658388
大小:67.08 KB
页数:7页
时间:2019-02-14
《spihc595显示数码管主函数》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、主函数volatileunsignedintcountnum=0;voidtimerl_init(void)TCCR1B==0x00;//stopTCNT1H==0x8F;//setupTCNT1L==0x81;OCR1AH=0x70;OCR1AL:=0x7F;OCR1BH=0x70;OCR1BL==0x7F;OCR1CH=0x70;OCR1CL==0x7F;ICR1H=:0x70;ICR1L=0x7F;TCCR1A==0x00;TCCR1B==0x04;//startTimer#pragmainterrupt_handlertimerl_ovf_isr:15voidtime
2、rl_ovMsr(void){TCNT1H=0x8F;//reloadcounterhighvalueTCNT1L=0x81;//reloadcounterlowvaluecountnum++;if(countnum>9999)countnum=0;}voidinit_devices(void){CLI();//disableallinterruptstimerl_init();TIMSK=0x04;//timerinterruptsourcesSEI();//re-enableinterruptsvoidmain(void)init_devices();HC_595Jnit
3、();while(l){Seg7_Led_display(countnum);//Seg7_Led_float(25.13);}函数1voidspi」nit(void){DDRB
4、=(1«MOSI)
5、(1«SCK)
6、(1«SS);//设置mosi,sck输出SPCR=(1«SPE)
7、(1«MSTR)
8、(1«SPRO)
9、(1«SPR1);//使spi主机模式rTwrTwrj>
10、/voidSPI_MasterTransmit(charData){/*启动数据传输*/SPDR=Data;/*等待传输结束*/while(!(SPSR&(1«SPIF)))函数2Hc595・c^2#•”^£*^£>•”^£*/rTwrXwrTwrTwrTwejwrT>eTwrT»rjwrTw•'.rTw•'.rTw•'.rTw•'.rTw•'.rTw•'.*.^i9•#*^S9・丫.♦卜11、ata[]={0x3F,0x06^0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F,//abcde』〃5,6,7,&90x77,0x7C,0x39,0x5E,0x79,0x71,0x00};volatileunsignedcharSeg7_Led_Buf[4],point=0,point_pos=0;//pointE^DiEypa±ed%ru±16DDiEypapoint_pos±iE%DiEypahOAHc595初始化k!>k!>rj«rj*rj*rj*rj*rj«rj*rj*rj*rj«rj*rj«rj*rj*rj*rj*12、j*rj*rj*rjw13、w^Jwrjw14、w^Jwrjwr15、wrjwrjwr16、wrjwrjwrjwrjwrjw•匕*&•■匕*&•■匕*&•■匕*&•■匕<&••匕/<2wrj・—p%.17、=(1«OE);PORTC&=(1«OE);PORTB=OxOF;spi_init();Seg7_Led_Buf[0]=16;Seg7_Led_Buf[l]=16;Seg7_Led_Buf[2]=16;Seg7_Led_Buf[3]=16;//16E2ArOaE%£6<2#<2#%2>%£><2^ej>18、rj>rj・rj>rj・rj>V"J**5°hc595送数据^9^•if•if•沧•£••沧•£•*t*•£••沧•£••沧•£•*t*•£••£•*t«•£•<2^<2><2^%2><2><2><2^<2>rjw•卜•卜*J>rj*
11、ata[]={0x3F,0x06^0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F,//abcde』〃5,6,7,&90x77,0x7C,0x39,0x5E,0x79,0x71,0x00};volatileunsignedcharSeg7_Led_Buf[4],point=0,point_pos=0;//pointE^DiEypa±ed%ru±16DDiEypapoint_pos±iE%DiEypahOAHc595初始化k!>k!>rj«rj*rj*rj*rj*rj«rj*rj*rj*rj«rj*rj«rj*rj*rj*rj*12、j*rj*rj*rjw13、w^Jwrjw14、w^Jwrjwr15、wrjwrjwr16、wrjwrjwrjwrjwrjw•匕*&•■匕*&•■匕*&•■匕*&•■匕<&••匕/<2wrj・—p%.17、=(1«OE);PORTC&=(1«OE);PORTB=OxOF;spi_init();Seg7_Led_Buf[0]=16;Seg7_Led_Buf[l]=16;Seg7_Led_Buf[2]=16;Seg7_Led_Buf[3]=16;//16E2ArOaE%£6<2#<2#%2>%£><2^ej>18、rj>rj・rj>rj・rj>V"J**5°hc595送数据^9^•if•if•沧•£••沧•£•*t*•£••沧•£••沧•£•*t*•£••£•*t«•£•<2^<2><2^%2><2><2><2^<2>rjw•卜•卜*J>rj*
12、j*rj*rj*rjw13、w^Jwrjw14、w^Jwrjwr15、wrjwrjwr16、wrjwrjwrjwrjwrjw•匕*&•■匕*&•■匕*&•■匕*&•■匕<&••匕/<2wrj・—p%.17、=(1«OE);PORTC&=(1«OE);PORTB=OxOF;spi_init();Seg7_Led_Buf[0]=16;Seg7_Led_Buf[l]=16;Seg7_Led_Buf[2]=16;Seg7_Led_Buf[3]=16;//16E2ArOaE%£6<2#<2#%2>%£><2^ej>18、rj>rj・rj>rj・rj>V"J**5°hc595送数据^9^•if•if•沧•£••沧•£•*t*•£••沧•£••沧•£•*t*•£••£•*t«•£•<2^<2><2^%2><2><2><2^<2>rjw•卜•卜*J>rj*
13、w^Jwrjw14、w^Jwrjwr15、wrjwrjwr16、wrjwrjwrjwrjwrjw•匕*&•■匕*&•■匕*&•■匕*&•■匕<&••匕/<2wrj・—p%.17、=(1«OE);PORTC&=(1«OE);PORTB=OxOF;spi_init();Seg7_Led_Buf[0]=16;Seg7_Led_Buf[l]=16;Seg7_Led_Buf[2]=16;Seg7_Led_Buf[3]=16;//16E2ArOaE%£6<2#<2#%2>%£><2^ej>18、rj>rj・rj>rj・rj>V"J**5°hc595送数据^9^•if•if•沧•£••沧•£•*t*•£••沧•£••沧•£•*t*•£••£•*t«•£•<2^<2><2^%2><2><2><2^<2>rjw•卜•卜*J>rj*
14、w^Jwrjwr
15、wrjwrjwr
16、wrjwrjwrjwrjwrjw•匕*&•■匕*&•■匕*&•■匕*&•■匕<&••匕/<2wrj・—p%.17、=(1«OE);PORTC&=(1«OE);PORTB=OxOF;spi_init();Seg7_Led_Buf[0]=16;Seg7_Led_Buf[l]=16;Seg7_Led_Buf[2]=16;Seg7_Led_Buf[3]=16;//16E2ArOaE%£6<2#<2#%2>%£><2^ej>18、rj>rj・rj>rj・rj>V"J**5°hc595送数据^9^•if•if•沧•£••沧•£•*t*•£••沧•£••沧•£•*t*•£••£•*t«•£•<2^<2><2^%2><2><2><2^<2>rjw•卜•卜*J>rj*
17、=(1«OE);PORTC&=(1«OE);PORTB=OxOF;spi_init();Seg7_Led_Buf[0]=16;Seg7_Led_Buf[l]=16;Seg7_Led_Buf[2]=16;Seg7_Led_Buf[3]=16;//16E2ArOaE%£6<2#<2#%2>%£><2^ej>
18、rj>rj・rj>rj・rj>V"J**5°hc595送数据^9^•if•if•沧•£••沧•£•*t*•£••沧•£••沧•£•*t*•£••£•*t«•£•<2^<2><2^%2><2><2><2^<2>rjw•卜•卜*J>rj*
此文档下载收益归作者所有