教学文库网 - 权威文档分享云平台
您的当前位置:首页 > 精品文档 > 实用模板 >

线阵LED图文显示(5)

来源:网络收集 时间:2026-07-22
导读: /****开机自检函数****/ void Turn_on_test() { uint i; uint temp=0x0001; for(i=0;i /****同心圆****/ void draw_circle() { uint i; uint temp; temp=0x8000; for(i=0;i delay_ms(300); //间隔0.3s temp>>=1; }

/****开机自检函数****/

void Turn_on_test() {

uint i;

uint temp=0x0001; for(i=0;i<16;i++) { display(1,temp); //高电平点亮 delay_ms(1000); //间隔1s temp<<=1; } }

/****同心圆****/ void draw_circle() {

uint i; uint temp; temp=0x8000;

for(i=0;i<16;i++) //从小到大 { display(1,temp);

delay_ms(300); //间隔0.3s temp>>=1; }

temp=0x0001;

for(i=0;i<16;i++) //从大到小 { display(1,temp);

delay_ms(300); //间隔0.3s temp<<=1; } }

/****TI杯程序****/

void draw_TI_cup(uchar const *p) {

uint i; uint temp;

p=&sort_buff2[0];

for(i=0;i<32;i++) //32列 {

temp=*p++; //将一竖的两个字节合成一个字

16

temp<<=8; temp|=*p++; display(0,temp);

delay_320us(1); //间隔320us } }

/*****秒针程序****/ void draw_second_hand() {

uint temp1,temp2; temp1=0xfffc; temp2=0x0000;

delay_320us(2*(60-ts)); //延时,等待指向相应的位置 display(1,temp1|0x0001);

delay_320us(1); //在该亮的位置显示320us display(1,temp2|0x0001); }

/****主函数****/ void main(void) {

mcu_init(); TIMER_init(); P1_port_init();

Re_sort(); //从新排序 Turn_on_test(); //开机自检 _EINT(); //开总中断 while(1) {

}; }

#pragma vector=PORT1_VECTOR __interrupt void P1_port(void) {

if(P1IFG&BIT5) //按键切换模式 {

delay_ms(30);

if(P1IFG&BIT5)

17

{

P1IFG &=~(BIT5); count++;

if(count>=5) count=1; while(!(P1IN&BIT5)); } }

if(P1IFG&BIT1) {

P1IFG &=~(BIT1); if(count==1) {

P1IE&=~BIT1; //关中断 draw_circle();

P1IE|=BIT1; //同心圆显示完后开中断 }

else if(count==2) //每次霍尔中断就显示一次TI杯 {

P2OUT|=L_OE;

draw_TI_cup(sort_buff2); P2OUT|=L_OE; }

else if(count==3) {

TACTL|=MC_1; //开始定时 draw_second_hand(); }

else if(count==4) {

Clock_buff[0]=ts+0x30; Clock_buff[1]=ts/10+0x30; Clock_buff[3]=tm+0x30; Clock_buff[4]=tm/10+0x30; Clock_buff[6]=th+0x30; Clock_buff[7]=th/10+0x30; disp_ascii(Clock_buff); } } }

//Timer A0 interrupt service routine #pragma vector=TIMER0_A0_VECTOR __interrupt void Timer_A0 (void) {

18

t50ms++; if(t50ms==20) {

t50ms=0; ts++; if(ts==60) {

ts=0; tm++; if(tm==60) {

tm=0;th++; if(th==24) th=0; } } } }

线阵LED图文显示(5).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.jiaowen.net/wendang/520234.html(转载请注明文章来源)
Copyright © 2020-2025 教文网 版权所有
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:78024566 邮箱:78024566@qq.com
苏ICP备19068818号-2
Top
× 游客快捷下载通道(下载后可以自由复制和排版)
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能出现无法下载或内容有问题,请联系客服协助您处理。
× 常见问题(客服时间:周一到周五 9:30-18:00)