《TM1812的原控制程序》由会员分享,可在线阅读,更多相关《TM1812的原控制程序(6页珍藏版)》请在金锄头文库上搜索。
1、/*VCC=9V,VDD电阻=51KVDD=55V,33M晶振,高速,“0码”高电平120nsX520ns,a1码”高电平500nsX不限一个nop30nS#mclude#include#defineucharunsignedchardefineumtunsignedmtdefinenop()_nop_()defineRed1defineGreen2defineBlue3defineWrite4defineHigh1#defineLow0sbitDIO=P1A0;bdatauchaia;sbita7=aA7;sbitLED=P2A2;uchaishow12,coloi-1,temp=Oxff;
2、voiddelay_ms(iiitz)mtx,y;fbi(x=z;x0;x)for(y=110;y0;y-);/*voidwrite(uchardate)/低速,33M、高速时两倍uchari;for(i=0;i8;i+)if(date&0x80)DIO=1;nop();nop();nop();nop();nop();nop();nop();nop();nop();nop();nop();nop();nop();nop();nop();nop();nop();nop();nop();nop();nop();nop();nop();nop();nop();nop();nop();nop();no
3、p();nop();nop();nop();nop();nop();nop();nop();nop();nop();nop();nop();nop();nop();nop();nop();nop();nop();nop();nop();nop();nop();nop();nop();nop();nop();DIO=0:nop();nop();nop();nop();nop();nop();nop();nop();nop();nop();nop();elseDIO=1;nop();nop();nop();nop();nop();nop();nop();nop();nop();nop();nop(
4、);nop();nop();nop();nop();nop();nop();nop();nop();nop();DIO=0:nop();nop();nop();nop();nop();nop();nop();nop();nop();nop();nop();nop();nop();nop();nop();date=l;*/voidwrite(uchardate)/高速,0码500n.l码lOOOn(33M)uchari;for(i=O;i8;i+)if(date&Ox8O)nop();nop();nopQ;nopQ;nop();nopQ;nopQ;nopQ;nop();nopQ;nopQ;nop
5、();最少14个nop();nopQ;nopQ;nopQ;/多无限nop();nop();nopQ;nopQ;nop();nop();nopQ;nopQ;nop();nop();nop();/27个nop可用.940NSDIO=0:DIO=1;nop.550NS可用,elseDIO=1120NSnop();nop();nopQ;nop();nop();nop();nopQ;nop();nop();nop();/10个nop可用,420NSnop();/nopQ;/最少单单一个DIO=l;120nS,可用/nop();最多13个nop,520NS可用/nopQ;/1812.0921D加这一个no
6、p,不可用DIO=0:nop();nop();nop();nop();nop();nop();nop();nop();nop();nop();date=l;voiddisplay()ucharij;for(j=Oj3j+)/芯片个数for(i=0;i12;i+)/1812就是3*4=12,1809就是3*3=9,1803、4就是3*1=3write(showi);voidloadQuchari;for(i=0;i4;i+)/载入灯组数,1812则载入4组灯,1809则载入3组灯,1803、4则有1if(coloi-=Red)showi*3-r0=temp;showi*3+l=0x00;show
7、i*3+2=0x00;if(coloi-=Green)showi*3T=0x00;showi*3+l=temp;showi*3+2=0x00;if(coloi-=Blue)showi*3T=0x00;showi*3+l=0x00;showi*3+2=temp;if(coloi-=Wnte)showi*3+0=temp;showi*3+l=temp;showi*3+2=temp;voidshow_3()for(colo尸1;co1ot5;co1oi+)五种颜色;依次变化R、G、E、Wfor(temp=0:temp0;temp-)/256级灰度从Oxff到0x00load();displayQ;d
8、elav_nis(50);voidshow_10四组灯依次红绿蓝uchari;for(i=0;i2;i+)wiite(Oxff);wiite(OxOO);write(Oxaa);wiite(Oxff);wiite(OxOO);write(Oxaa);wiite(Oxff);wiite(OxOO);write(Oxaa);wiite(Oxff);wiite(Oxff);wiite(OxOO);voidmain()ucharij;for(j=0j4j+)fbr(i=O;i3;i+)wnte(Oxfi);delay_ms(50);while(l)show_3();show_l();/*fdr(j=0
9、:j4j+)fbr(i=O;i3;i+)write(Oxaa);*/delay_ms(50);严nop();nopQ;nop();nop();nopQ;nop();nop();nopQ;nopQ;nop();nopQ;nopQ;nop();nopQ;nopQ;nop();nopQ;nopQ;nop();nopQ;nopQ;nop();nopQ;nopQ;nop();nopQ;nopQ;nop();nopQ;nopQ;nop();nopQ;nopQ;nop();nopQ;nopQ;nop();nopQ;nopQ;nop();nopQ;nopQ;nop();nopQ;nopQ;nop();nopQ
10、;nopQ;nop();nopQ;nopQ;nop();nopQ;nopQ;nop();nopQ;nopQ;nop();nopQ;nopQ;nop();nopQ;nopQ;nop();nopQ;nopQ;nop();nopQ;nopQ;nop();nopQ;nopQ;nop();nop();nop();nopQ;nopQ;nop();nop();nopQ;nopQ;nop();nop();nopQ;nopQ;nop();nop();nopQ;nopQ;nop();nop();nopQ;nopQ;nop();nop();nopQ;nopQ;nop();nop();nopQ;nopQ;nopQ;n
11、op();nopQ;nopQ;nop();nop();nopQ;nopQ;nop();nop();nopQ;nopQ;nopQ;nop();nopQ;nopQ;nop();nop();nopQ;nopQ;nop();nop();nopQ;nopQ;nop();nop();nop();nopQ;nop();nop();nopQ;nopQ;nop();nop();nopQ;nopQ;nop();nop();nopQ;nopQ;nop();nop();nopQ;nopQ;nop();nop();nopQ;nopQ;nop();nop();nopQ;nopQ;nop();nopQ;nopQ;nopQ;
12、nop();nop();nopQ;nopQ;nop();nop();nopQ;nopQ;nopQ;nop();nopQ;nopQ;nop();nop();nop();nopQ;nop();nop();2/IV/IV/IV/IV/IVZ(Y/IV/IVZ(Y/IV/IVZ(YopopopopopopopopopopopoppnISISISISIS?.7ISIS?.7ISIS?.75optn2/IV/IV/IV/IV/IV/IV/IVZ(Y/IV/IVopopopopopopopopopoppnISISISISISISIS?.7ISIS)7nopQ;nopO;/300NSnopQ;nopQ;/60
13、0nopQ;nop0;/900nopQ;nopQ;/1200nopQ;nopQ;nopQ;nopQ;nopQ;nopQ;nopQ;nopQ;/2400nopQ;nopQ;nopQ;nopQ;nopQ;nopQ;nopQ;nopQ;nopQ;nopQ;nopQ;nopQ;nopQ;nopQ;nopQ;nopQ/4800nopQ;nopQ;nopQ;nopQ;nopQ;nopQ;nop();nopQ;nopQ;nopQ;nopQ;nopQ;/nopQ;nop();/2nopQ;nopQ;nopQ;nopO;行复位nop();nop();nopQ;/*/*nop();nopQ;nopQ;nopQ;nopQ;nop();nop();/此nop();nopQ;nop();nopQ;nopQ;nop();nop();nop();nopQ;nopQ;nop();nopQ;nop();nopQ;nopQ;