完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
#include"STC15F2K60S2.h"
#define Segs P0 #define Out P1 #define Anm_speed 4 unsigned char code table[]={ //第0帧 0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x01, 0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x01, 0x02,0x02,0x02,0x02,0x02,0x02,0x01,0x01, 0x02,0x02,0x02,0x02,0x02,0x02,0x01,0x01, 0x02,0x02,0x02,0x02,0x02,0x02,0x01,0x01, 0x02,0x02,0x02,0x02,0x02,0x02,0x01,0x01, 0x02,0x02,0x02,0x02,0x02,0x02,0x01,0x01, 0x02,0x02,0x02,0x02,0x02,0x02,0x01,0x01, //第1帧 0x01,0x01,0x01,0x01,0x01,0x01,0x03,0x03, 0x01,0x01,0x01,0x01,0x01,0x01,0x03,0x03, 0x01,0x01,0x01,0x01,0x01,0x01,0x03,0x03, 0x01,0x01,0x01,0x01,0x01,0x01,0x03,0x03, 0x01,0x01,0x01,0x01,0x01,0x03,0x03,0x03, 0x01,0x01,0x01,0x01,0x01,0x03,0x03,0x03, 0x01,0x01,0x01,0x01,0x01,0x03,0x03,0x03, 0x01,0x01,0x01,0x01,0x01,0x03,0x03,0x03, //第2帧 0x03,0x03,0x03,0x03,0x07,0x07,0x07,0x07, 0x03,0x03,0x03,0x03,0x07,0x07,0x07,0x07, 0x03,0x03,0x03,0x03,0x07,0x07,0x07,0x07, 0x03,0x03,0x03,0x03,0x07,0x07,0x07,0x07, 0x03,0x03,0x03,0x03,0x07,0x07,0x07,0x07, 0x03,0x03,0x03,0x07,0x07,0x07,0x07,0x07, 0x03,0x03,0x03,0x07,0x07,0x07,0x07,0x07, 0x03,0x03,0x03,0x07,0x07,0x07,0x07,0x07, //第3帧 0x07,0x07,0x07,0x07,0x07,0x0F,0x0F,0x0F, 0x07,0x07,0x07,0x07,0x07,0x0F,0x0F,0x0F, 0x07,0x07,0x07,0x07,0x07,0x0F,0x0F,0x0F, 0x07,0x07,0x07,0x07,0x07,0x0F,0x0F,0x0F, 0x07,0x07,0x07,0x07,0x07,0x0F,0x0F,0x0F, 0x07,0x07,0x07,0x07,0x0F,0x0F,0x0F,0x0F, 0x07,0x07,0x07,0x07,0x0F,0x0F,0x0F,0x0F, 0x07,0x07,0x07,0x07,0x0F,0x0F,0x0F,0x0F, //第4 //第827帧 0x00,0x7E,0x80,0x80,0x80,0x80,0x7E,0x00, 0x00,0x7E,0x80,0x80,0x80,0x80,0x7E,0x00, 0x00,0x7E,0x80,0x80,0x80,0x80,0x7E,0x00, 0x00,0x7E,0x80,0x80,0x80,0x80,0x7E,0x00, 0x00,0x7E,0x80,0x80,0x80,0x80,0x7E,0x00, 0x00,0x7E,0x80,0x80,0x80,0x80,0x7E,0x00, 0x00,0x7E,0x80,0x80,0x80,0x80,0x7E,0x00, 0x00,0x7E,0x80,0x80,0x80,0x80,0x7E,0x00, }; unsigned char code Segs_tab[]={ 0xe0,0xe1,0xe2,0xe3,0xe4,0xe5,0xe6,0xe7,0xe8,0xe9,0xea,0xeb,0xec,0xed,0xee,0xef, 0xd0,0xd1,0xd2,0xd3,0xd4,0xd5,0xd6,0xd7,0xd8,0xd9,0xda,0xdb,0xdc,0xdd,0xde,0xdf, 0xb0,0xb1,0xb2,0xb3,0xb4,0xb5,0xb6,0xb7,0xb8,0xb9,0xba,0xbb,0xbc,0xbd,0xbe,0xbf, 0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0x7b,0x7c,0x7d,0x7e,0x7f, }; unsigned char idata Rec_buf[64]={ 0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, }; ***it Rest=P3^0; void IO_Interrupt_UART_Init(); unsigned char T1_count=0,Anm1=0,Mode=0,Rec_count=0; unsigned int End,Anm=0; void main() { End=sizeof(table); IO_Interrupt_UART_Init(); while(1) { if(Anm>End)Anm=0; Segs=Segs_tab[Anm1]; switch (Mode) { case 0:Out=table[Anm1+Anm];break; case 1:Out=Rec_buf[Anm1];break; default:break; } } } void IO_Interrupt_UART_Init() { P0M1=0x00; P0M0=0x00; P1M1=0x00; P1M0=0xff; EA=1; EX0=1; IT0=1; ET0=1; ET1=1; ES=1; AUXR |= 0x80; //定时器时钟1T模式 TMOD &= 0xF0; //设置定时器模式 TL0 = 0x5C; //设置定时初值 TH0 = 0xF7; //设置定时初值 TF0 = 0; //清除TF0标志 TR0 = 1; //定时器0开始计时 AUXR &= 0xBF; //定时器时钟12T模式 TMOD &= 0x0F; //设置定时器模式 TL1 = 0x00; //设置定时初值 TH1 = 0x70; //设置定时初值 TF1 = 0; //清除TF1标志 TR1 = 1; //定时器1开始计时 SCON = 0x50; //8位数据,可变波特率 AUXR |= 0x04; //定时器2时钟为Fosc,即1T T2L = 0xD0; //设定定时初值 T2H = 0xFF; //设定定时初值 AUXR |= 0x01; //串口1选择定时器2为波特率发生器 } void Button() interrupt 0 { Mode=Mode+1; if(Mode==1) { AUXR |= 0x10; ET1=0; TR1=0; Anm=0; Anm1=0; } if(Mode>1)IAP_CONTR=0x60; } void Display_delay() interrupt 1 { TR0=0; Anm1=Anm1+1; if(Anm1>63)Anm1=0; Out=0x00; Segs=0xff; TR0=1; } void LED_Display() interrupt 3 { TR1=0; T1_count++; if(T1_count==Anm_speed) { T1_count=0; Anm=Anm+64; } TR1=1; } void uart_receive() interrupt 4 { unsigned char ch; ES=0; if(RI) { ch=SBUF; Rec_buf[Rec_count]=ch; Rec_count++; if(Rec_count>63)Rec_count=0; } RI=0; ES=1; } |
|
相关推荐
1个回答
|
|
看看手册有没有IO口功能不一样的
|
|
|
|
你正在撰写答案
如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。
644 浏览 0 评论
求助一下关于51系列单片机的Timer0的计时问题,TH0、TL0+1的时间是怎么算的?
1819 浏览 1 评论
【RA-Eco-RA4E2-64PIN-V1.0开发板试用】开箱+Keil环境搭建+点灯+点亮OLED
1262 浏览 0 评论
【敏矽微ME32G070开发板免费体验】使用coremark测试敏矽微ME32G070 跑分
1136 浏览 0 评论
【敏矽微ME32G070开发板免费体验】开箱+点灯+点亮OLED
1357 浏览 2 评论
【youyeetoo X1 windows 开发板体验】少儿AI智能STEAM积木平台
12024 浏览 31 评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-24 02:26 , Processed in 0.683650 second(s), Total 74, Slave 57 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号