lanpxr:
您好!我也刚学单片机,这是我用HT的单片机做的一个控制LED亮度的程序,由于我目前没有条件搭线,所以想请高手帮忙指点一下.看看小弟还有那些不足的地方.呵呵我还是个学生呢.#includeht46r47.inc;Pb2控制占空比;Pc1,Pc2输出PWM;Pb1选择Pc1或Pc2data.section'data't0 db?;ThecycleofPWMpulset10db?;Opentimeaaadb?;Opentimecontrolbbbdb?;Closetimecontrolsovdb?;Opentimeendbovdb?;closetimeendcode.section'code'org 00hclr pbcmov a,02hmov pbc,ajmp startorg 08hjmp pwm;+++++++++++++++++++++++++++++++++++++++++++++++start:mov a,3 ;cycleofPWMpulsemov t0,amov aaa,amov a,1set sovclr bbbclr t10;+++++++++++++++++++++++++++++++++++++++++++++main:mov a,05hmov intc,amov a,84hmov tmrc,a;fsys=32768Hz,rtc,t0=fsys/32=0.5msmov a,0feh;Theclockbasethistimemov tmr,aset tmrc.4jmp $;+++++++++++++++++++++++++++++++++++++++++++++++++++++++sz pb.1 ;判断键是否按下jmp loopcallchouloop:sz sovjmp next1sz bovjmp next2jmp loopnext1:inc t10mov a,aaasub a,t10mov sov,asz sovretisz bovjmp $1set sovjmp loop$1:cpl pcset bovretinext2:inc t20mov a,bbbmov bov,asz bovretisz sovjmp $1jmp loop$1:cpl pcset sovreti;+++++++++++++++++++++++++++++++++++++++++++++++++chouprocsdz aaajmp $1jmp start$1:mov a,t0sub a,aaamov bbb,aretchouendpend