利用proteus搭建电路
实现如下功能:
第一次按下K1键,输出三角波
第二次按下K1键,输出锯齿波
第三次按下K1键,输出方波
第四次按下K1键,输出正弦波
第五次按下K1键,输出-2.5V电平
源代码:
- ORG 0000H
- LJMP MAIN
- ORG 0003H
- LJMP EX0P
- ORG 0100H
- MAIN: MOV SP,#60H
- MOV R2,#0
- SETB IT0
- SETB EX0
- SETB EA
- LP0: CJNE R2,#0,LP1
- ACALL LINE
- LP1: CJNE R2,#1,LP2
- ACALL TRI
- LP2: CJNE R2,#2,LP3
- ACALL SAWTOOTH
- LP3: CJNE R2,#3,LP4
- ACALL SQUARE
- LP4: CJNE R2,#4,LP5
- ACALL SINE
- LP5: JMP LP0
- EX0P: INC R2
- CJNE R2,#5,RETU
- MOV R2,#0
- RETU: RETI
- LINE: MOV A,#80H
- MOV DPTR,#7F00H
- MOVX @DPTR,A
- RET
- TRI: MOV A,#00H
- MOV DPTR,#7F00H
- UP: MOVX @DPTR,A
- ACALL DELAY
- INC A
- JNZ UP
- MOV A,#0FEH
- DOWN: MOVX @DPTR,A
- ACALL DELAY
- DEC A
- JNZ DOWN
- RET
- SAWTOOTH:CLR A
- MOV DPTR,#7F00H
- NEXTS: MOVX @DPTR,A
- ACALL DELAY
- INC A
- JNZ NEXTS
- RET
- SQUARE: MOV A,#0FFH
- LPSQU: MOV DPTR,#7F00H
- MOVX @DPTR,A
- ACALL DELAY
- CPL A
- MOVX @DPTR,A
- ACALL DELAY
- RET
- SINE: MOV R6,#255
- MOV DPTR,#7F00H
- CLR A
- MOV B,A
- NEXTSINE:
- MOVC A,@A+PC
- MOVX @DPTR,A
- ACALL DELAY
- INC B
- MOV A,B
- DJNZ R6,NEXTSINE
- RET
-
- DELAY: MOV R7,#150
- DL: DJNZ R7,DL
- RET
-
- SINEDAT: DB 80H,83H,86H,89H,8cH,8fH,92H,95H,98H,9cH,9fH,0a2H,0a5H,0a8H,0abH,0aeH
- DB 0b0H,0b3H,0b6H,0b9H,0bcH,0bfH,0c1H,0c4H,0c7H,0c9H,0CCH,0ceH,0d1H,0d3H,0d5H,0d8H
- DB 0daH,0dcH,0deH,0e0H,0e2H,0e4H,0e6H,0e8H,0eaH,0ecH,0edH,0efH,0f0H,0f2H,0f3H,0f4H
- DB 0f6H,0f7H,0f8H,0f9H,0faH,0fbH,0fcH,0fcH,0fdH,0feH,0feH,0ffH,0ffH,0ffH,0ffH,0ffH
-
- DB 0ffH,0ffH,0ffH,0feH,0feH,0fdH,0fcH,0fcH,0fbH,0faH,0f9H,0f7H,0f6H,0f5H,0f3H,0f2H
- DB 0f0H,0efH,0edH,0eBH,0E9H,0E7H,0E5H,0E3H,0E1H,0DFH,0DCH,0DAH,0D8H,0D5H,0D3H,0D1H
- DB 0CEH,0CCH,0c9H,0c7H,0c4H,0c1H,0bfH,0bcH,0b9H,0b6H,0b3H,0b0H,0aeH,0abH,0a8H,0a5H
- DB 0a3H,0A1H,09EH,09cH,098H,095H,092H,08fH,08cH,089H,087H,085H,083H,081H,080H,080H
-
- DB 080H,080H,07FH,07EH,07BH,078H,075H,072H,06fH,06cH,069H,066H,063H,060H,05dH,05aH
- DB 057H,054H,051H,04EH,04bH,048H,046H,043H,040H,03dH,03bH,038H,035H,033H,030H,02eH
- DB 02cH,029H,027H,025H,023H,020H,01EH,01CH,01AH,018H,017H,015H,013H,012H,010H,00EH
- DB 00DH,00CH,00CH,0AH,009H,008H,007H,006H,005H,004H,003H,002H,001H,001H,000H,000H
-
- DB 000H,000H,000H,000H,001H,001H,002H,003H,003H,004H,005H,006H,007H,008H,009H,00aH
- DB 00CH,00dH,00eH,010H,012H,013H,015H,017H,018H,01aH,01CH,01eH,020H,023H,025H,027H
- DB 029H,02cH,02eH,030H,033H,035H,038H,03bH,03dH,040H,043H,046H,048H,04bH,04eH,051H
- DB 054H,057H,05aH,05dH,060H,063H,066H,069H,06cH,06fH,072H,075H,078H,07BH,07EH,080H
- END
复制代码
【必读】版权免责声明
1、本主题所有言论和内容纯属会员个人意见,与本论坛立场无关。2、本站对所发内容真实性、客观性、可用性不做任何保证也不负任何责任,网友之间仅出于学习目的进行交流。3、对提供的数字内容不拥有任何权利,其版权归原著者拥有。请勿将该数字内容进行商业交易、转载等行为,该内容只为学习所提供,使用后发生的一切问题与本站无关。 4、本网站不保证本站提供的下载资源的准确性、安全性和完整性;同时本网站也不承担用户因使用这些下载资源对自己和他人造成任何形式的损失或伤害。 5、本网站所有软件和资料均为网友推荐收集整理而来,仅供学习用途使用,请务必下载后两小时内删除,禁止商用。6、如有侵犯你版权的,请及时联系我们(电子邮箱1370723259@qq.com)指出,本站将立即改正。
|
|