返回列表 发帖

基于AT89C2051的红外遥控学习器源程序

  1. ORG 0000H

  2. AJMP MAIN

  3. ORG 0003H

  4. AJMP KEYPRESS

  5. ORG 000BH

  6. AJMP TIMEOUT

  7. ORG 001BH

  8. AJMP TIMEOUT



  9. SENDDUAN BIT P3.0

  10. JIEDUAN BIT P3.1

  11. INTRPO BIT P3.2

  12. JIEXUAN BIT P3.3

  13. SENDLIGHT BIT P3.4

  14. JIELIGHT BIT P3.5

  15. CS BIT P3.7

  16. DATADUAN BIT P1.6

  17. CLK BIT P1.7

  18. JIANWEI EQU R5

  19. JIANMA EQU R6

  20. SHANGJIAN EQU 07H;R7

  21. OPENKEY EQU 81H

  22. CLOSEKEY EQU 00H

  23. CHUT0 EQU 11H

  24. CHUT1 EQU 11H

  25. BUFBEGIN EQU 18H

  26. OPENT1 EQU 88H

  27. CLOSET1 EQU 00H

  28. OPENT0 EQU 82H

  29. CLOSET0 EQU 00H

  30. DATABEG1 EQU 0AAH

  31. DATABEG2 EQU 33H



  32. ORG 0030H

  33. MAIN: MOV IE,#80H

  34. MOV IP,#00H

  35. MOV P3,#0FFH

  36. CLR CS

  37. SETB P1.0

  38. SETB P1.1

  39. SETB P1.2

  40. CLR P1.3

  41. CLR P1.4

  42. CLR P1.5

  43. CLR P1.6

  44. CLR P1.7



  45. MOV R3,#80H

  46. MOV R0,00H

  47. CYCLE1: MOV @R0,#00H

  48. INC R0

  49. DJNZ R3,CYCLE1



  50. MOV PSW,#00H

  51. MOV SP,#07H



  52. MOV TMOD,#11H

  53. MOV TCON,#00H



  54. START: MOV SP,#07H

  55. SETB SENDDUAN

  56. CLR F0

  57. SETB EXO

  58. WAITKEY: MOV C,F0

  59. JNC WAITKEY

  60. CJNC JIANMA,#1BH,SEND

  61. LCALL LEARNP

  62. LJMP START

  63. SEND: LCALL SENDP

  64. LJMP START



  65. SENDP: SETB SENDDUAN

  66. CLR F0

  67. MOV TMOD,#CHUT1

  68. CLR SENDLIGHT

  69. MOV A,JIANMA

  70. CJNE A,SHANGJIAN,SAME

  71. SAME: MOV R0,#BUFBEGIN

  72. CLR TR1

  73. LJMP NEXT3

  74. RETURN: CLR ET1

  75. SETB SENDDUAN

  76. SETB SENDLIGHT

  77. CLR F0

  78. LCALL DELAY

  79. RET

  80. NEXT3: CPL F0

  81. JB F0,SEND1

  82. SEND0: CLR C ;1

  83. MOV A,#0FFH

  84. SUBB A,@R0

  85. MOV R2,A ;1

  86. INC R0 ;1

  87. MOV A,#0FFH ;1

  88. SUBB A,@R0 ;1

  89. MOV R3,A

  90. INC R0

  91. CLR C

  92. MOV A,#4FH

  93. ADDC A,R2

  94. MOV R2,A

  95. MOV A,R3

  96. ADDC A,#00H

  97. MOV R3,A

  98. MOV TL1,R2

  99. MOV TH1,R3

  100. SETB TR1 ;1

  101. SETB ET1 ;1

  102. SEND1: CLR C

  103. MOV A,#0FFH

  104. SUBB A,@RO

  105. MOV TL1,A

  106. INC R0

  107. MOV A,#0FFH

  108. SUBB A,@R0

  109. MOV TH1,A

  110. INC R0

  111. SETB TR1

  112. SETB ET1

  113. NEXT6: CLR SENGGUAN

  114. MOV R3,#03H

  115. NEXT4: DJNZ R3,NEXT4

  116. SETB SENDDUAN

  117. MOV R3,#07H

  118. NEXT5: DJNZ R3,#NEXT5

  119. SJMP NEXT6



  120. TIMA1OUT: CLR ET1 ;2

  121. CLR TR1 ;2

  122. SETB SENDDUAN ;1

  123. CJNE@R0,#DATABEG2,TIM1NT2

  124. MOV DPTR,#RETURN ;2

  125. MOV R1,SP ;2

  126. MOV @R1,DPH ;2

  127. DEC R1 ;1

  128. MOV @R1,DPL ;2

  129. RETI ;2

  130. TIM1NET2: DEC R0

  131. TIM1NET1: CPL F0 ;1

  132. JB F0,SEND11 ;2

  133. SEND00: MOV DPTR,#SENDO ;11

  134. MOV R1,SP

  135. MOV @R1,DPH

  136. DEC R1

  137. MOV @R1,DPL

  138. RETI

  139. SEND11: MOV DPTR,#SEND1 ;11

  140. MOV R1,SP

  141. MOV @R1,DPH

  142. DEC R1

  143. MOV @R1,DPL

  144. RETI

  145. LEARNP: MOV R2,#02H

  146. NEXT91: MOV R3,#0FFH

  147. NEXT81: MOV R4,#0FFH

  148. NEXT71: DJNZ R4,NEXT71

  149. DJNZ R3,NEXT81

  150. GJNZ R2,NEXT91

  151. CLR F0

  152. SETB EX0

  153. MOV R2,#0AH

  154. MEXT9: MOV R3,#0FFH

  155. NEXT8: MOV R4,#0FFH

  156. NEXT7: JB F0,NEXT10

  157. DJNZ R4,NEXT7

  158. DJNZ R3,MEXT8

  159. DJNZ R2,NEXT9

  160. CLR EX0

  161. RET

  162. NEXT10: CJNE JIANMA,#1BH,NEXT11

  163. LJMP NEXT111

  164. NEXT11: RET

  165. NEXT111: CLR JIELIGHT

  166. CLR JIEXUAN

  167. CLR F0

  168. MOV R0,#BUFBEGIN

  169. SETB ET0

  170. MOV TCON,#00H

  171. MOV TMOD,#CHUT0

  172. MOV TL0,#00H

  173. MOV TH0,#00H

  174. MOV R2,#02H

  175. NEXT92: MOV R3,#0FFH

  176. NEXT82: MOV R4,#0FFH

  177. NEXT72: DJNZ R4,NEXT72

  178. DJNZ R3,NEXT82

  179. DJNZ R2,NEXT92



  180. CLR TR0

  181. L1: MOV C,JIEDUAN

  182. JC L1

  183. L4: SETB TR0

  184. L2: MOV C,JIEDUAN

  185. CLR TR0

  186. MOV @R0,TL0

  187. INC R0

  188. MOV TH0,#00H

  189. MOV TL0,#00H

  190. L6: SETB TR0

  191. L3: MOV C,JIEDUAN

  192. JC L3

  193. CLR TR0

  194. CLR C

  195. MOV A,TL0

  196. ADDC A,#13H

  197. MOV @R0,A

  198. INC R0

  199. MOV TH0,#00H

  200. MOV TL0,#00H

  201. SETB TR0

  202. L5: MOV C,JIEDUAN

  203. JNC L5

  204. CLR TR0

  205. CLR C ;1

  206. MOV A,TL0 ;1

  207. ADDC A,#13H ;1

  208. MOV @R0,A ;2

  209. INC R0

  210. MOV A,TH0

  211. ADDC A,#00H

  212. MOV @R0,A

  213. INC R0

  214. MOV TH0,#00H

  215. MOV TL0,#00H

  216. SJMP L6

  217. SHUJIAN: SETB JIEXUAN

  218. MOV @R0,#DATABEG1

  219. INC R0

  220. MOV @R0,#DATABEG2

  221. SETB EX0

  222. CLR F0

  223. NEXT13: JB F0,NEXT12

  224. LJMP NEXT13

  225. NEXT12: LCALL WRITEP

  226. SETB JIELIGHT

  227. RET

  228. TIME0OUT CLR ET0

  229. CLR TR0

  230. MOV DPTR,#SHUJIAN

  231. MOV @R1,DPH

  232. DEC R1

  233. MOV @R1,DPL

  234. RETI

  235. KEYPRESS: CLR EX0

  236. MOV R3,#0DH

  237. CYCLE3: MOV R4,#0FFH

  238. CYCLE2: DJNZ R4,CYCLE2

  239. DJNZ R3,CYCLE3

  240. MOV C,INTRPO

  241. JNC NEXT1

  242. RETI

  243. NEXT1: SETB F0

  244. MOV C,P1.0

  245. MOV ACC.0,C

  246. MOV C,P1.1

  247. MOV ACC.1,C

  248. MOV C,P1.2

  249. MOV ACC.2,C

  250. CLR P1.0

  251. CLR P1.1

  252. CLR P1.2

  253. SETB P1.3

  254. SETB P1.4

  255. SETB P1.5

  256. MOV C,P1.3

  257. MOV ACC.3,C

  258. MOV C,P1.4

  259. MOV ACC.4,C

  260. MOV C,P1.5

  261. MOV ACC.5,C

  262. ANL A,300111111B

  263. MOV JIANMA,A

  264. SETB P1.0

  265. SETB P1.1

  266. SETB P1.2

  267. CLR P1.3

  268. CLR P1.4

  269. CLR P1.5

  270. LCALL JIANWEIP

  271. RETI

  272. JIANWEIP: CJNE JIANMA,#36H,NEXT14

  273. MOV JIANWEI,#01H

  274. LJMP LAST

  275. NEXT14: CJNE JIANMA,#35H,NEXT15

  276. MOV JIANWEI,#02H

  277. LJMP LAST

  278. NEXT15: CJNE JIANMA,#35H,NEXT16

  279. MOV JIANWEI,#03H

  280. LJMP LAST

  281. NEXT16: CJNE JIANMA,#2EH,NEXT17

  282. MOV JIANWEI,#04H

  283. LJMP LAST

  284. NEXT17: CJNE JIANMA,#2DH NEXT18

  285. MOV JIANWEI, #05H

  286. LJMP LAST

  287. NEXT18: CJNE JIANMA,#2BH,NEXT19

  288. MOV JIANWEL,#06H

  289. LJMP LAST

  290. NEXT19: CJNE JIANMA,#1EH,NEXT20

  291. MOV JIANWEI,#07H

  292. LJMP LAST

  293. NEXT20: CJNE JIANMA,#1DH,NEXT21

  294. MOV JIANWEL,#09H

  295. LJMP LAST

  296. NEXT21: CJNE JIANMA,#1BH,NEXT22

  297. MOV JIANWEI,#09H

  298. LJMP LAST

  299. NEXT22: CLR FO

  300. LAST: RET

  301. READP: MOV RO,BUFBEGIN

  302. MOV A,JIANWEI

  303. MOV B,50

  304. MUL AB

  305. MOV R3,A

  306. SHU JU DI ZHI

  307. INC R3

  308. LCALL READCOM

  309. READNET2: MOV A,R3

  310. LCALL WRITEADRESS

  311. LCALL READBYTE

  312. CJNE ,#DATABEG1,READNET1

  313. MOV A R3

  314. INC A

  315. LACLL WRITEADRESS

  316. LCALL READBYTE

  317. CJNE A,#DATABEG2,READNET1

  318. CLR CS

  319. RET

  320. READNET1: MOV @RO,A

  321. INC RO

  322. INC R3

  323. LJMP READNET2

  324. WRITEP: MOV RO,BUFBEGIN

  325. MOV A,JIAWEI

  326. MOV B,50

  327. MUL AB

  328. MOV R3,A ;KAI SHI SHU

  329. JU DI ZHI

  330. INC R3

  331. LCALL EWEN

  332. WRITNET1: LACLL WRITECOM

  333. MOV,R3

  334. LCALL WRITEADRESS

  335. MOV A,@RO

  336. CJNE A,#DATABEG1,WRITNET2

  337. INC RO

  338. MOV A,@RO

  339. CJNE A,DATABEG2,WRITNET3

  340. LCALL EWDS

  341. CLR CS

  342. RET

  343. WRITNRT3: DEC RO

  344. WRITNET2: LCALL WRITEBYTE

  345. INC RO

  346. INC R3

  347. LJMP WRITNE1

  348. RET

  349. WRITBYTE: MOV R2,#08H

  350. BOUT1: CLR CLK

  351. RLC A

  352. MOV DATADUAN,C

  353. NOP

  354. SETB CLK

  355. NOPDJNZ R2,BOUT1

  356. CLRDATADUAN

  357. RET

  358. READBYTE: SETB DATAUAN

  359. MOV R2,#08H

  360. BIN1: CLR CLK

  361. NOP

  362. SETB CLK

  363. NOP

  364. MOV C,DATADUAN

  365. RLC A

  366. DJNZ R2,BIN1

  367. RET

  368. READCOM: CLR CS

  369. CLR CLK

  370. SETB DATADUAN

  371. SETB CS

  372. NOP

  373. SETB CLK ;1

  374. NOP

  375. CLR CLK

  376. NOP

  377. SETB CLK ;1

  378. NOP

  379. CLR DATAUAN

  380. CLR CLK

  381. NOP

  382. SETB CLK ;0

  383. RET

  384. WRITECOM: CLR CS

  385. NOP

  386. CLR CLK

  387. SETB DATADUAN

  388. SETB CS

  389. NOP

  390. SETB CLK ;1

  391. NOP

  392. CLR DATADUAN

  393. NOP

  394. CLR CLK

  395. NOP

  396. SETB CLK ;0

  397. NOP

  398. SETB DATADUAN

  399. NOP

  400. CLR CLK

  401. NOP

  402. SETB CLK ;1

  403. RET

  404. WRITEADRESS: MOV R2,#07H

  405. RLC A ;TIAO GUO

  406. DI 7 WEI

  407. BOUT2: CLR CLK

  408. RLC A

  409. MOV DATADUAN,C

  410. NOP

  411. DJNA R2,BOUT2

  412. CLR DATAUAN

  413. RET

  414. EQEN: CLR CS

  415. CLR CLK

  416. SETB DATADUAN

  417. SETB CS

  418. SETB CLK ;1

  419. NOP

  420. CLR CLK

  421. NOP

  422. CLR DATADUAN

  423. SETB CLK ;0

  424. NOP

  425. NOP

  426. CLR CLK

  427. NOP

  428. SETB CLK ;0

  429. NOP

  430. NOP

  431. SETB DATADUAN

  432. CLR CLK

  433. NOP

  434. SETB CLK ;1

  435. NOP

  436. NOP

  437. SETB CLK ;1

  438. NOP

  439. NOP

  440. CLR CLK

  441. NOP

  442. NOP

  443. CLR CS

  444. RET

  445. EWDS: CLR CS

  446. CLR CLK

  447. SETB DATADUAN

  448. SETB CS

  449. SETB CLK ;1

  450. NOP

  451. CLR CLK

  452. NOP

  453. CLR DATADUAN

  454. SETB CLK ;0

  455. NOP

  456. NOP

  457. CLR CLK

  458. NOP

  459. SETB CLK ;0

  460. NOP

  461. NOP

  462. CLR CLK

  463. NOP

  464. NOP

  465. RETB CLK ;0

  466. NOP

  467. NOP

  468. SETB CLK ;0

  469. NOP

  470. NOP

  471. CLR CLK

  472. NOP

  473. NOP

  474. SETB CLK ;0

  475. NOP

  476. NOP

  477. CLR CS

  478. CLR CLK

  479. RET

  480. DELAY: MOV R3,#96H

  481. DEL1: MOV R4,#OFFH

  482. DEL2: DJNZ R4,DEL2

  483. DJNZ R3,#DEL1

  484. RET

  485. END
复制代码
一心一意做事,一心一意做人,做站如做人。关于网站上的事务你可以直接联系我:13320088060。

大家好好讨论一下,真不错






头盔的品牌 瑜伽垫哪个牌子好 汽车贴膜多少钱 扫地机价格

TOP

返回列表

最新关注 关闭


关于论坛注册,最新修改,请网友们注意

由于最近大量垃圾信息出现在我们的论坛,为了营造一个良好的氛围,目前论坛只开发邀请注册,你可以点击以下链接自动邀请注册(如果有人使用了点击下一个试一试) ...


查看
珩源工控论坛热诚欢迎您联系我们进行合作!

Powered by Discuz! 7.2© 2001-2009 Comsenz Inc.

珩源工控论坛 ( 桂ICP备19004328号) |论坛统计|WAP| 客服中心-www.hymcu.com
  

GMT+8, 2024-11-1 10:20, Processed in 1.054430 second(s), 5 queries, Gzip enabled.