资源描述:
《用单片机产生正弦波程序.doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、用单片机产生正弦波程序要用到数模转换DAC0832 MOV DPTR,#SINTAB ;正弦表写入内部RAM6DH-7FH MOV R0,#6DHLOOP: CLR A MOVCA,@A+DPTR MOV @R0,A INC DPTR INC R0 CJNER0,#80H,LOOP MOV DPTR,#7FFFH ;设置D/A转换器的端口地址 MOV R0,#6DH ;设置正弦表指针LOOP1:MOV A,@R0 ;查表
2、 MOVX@DPTR,A ;D/A转换 ACALL DELAY ;延时,等待转换结束 DEC R0 ;正弦表位移量增量 CJNER0,#6DH,LOOP1 ;第一象限输出完?LOOP2:MOV A,@R0 ;查表 MOVX@DPTR,A ;D/A转换 acall DELAY ;延时,等待转换结束 DEC R0 ;
3、正弦表位移量减量 CJNER0,#6DH,LOOP2 ;第二象限输出完?LOOP3:MOV A,@R0 ;查表 CPLA ;表值取反 MOVX@DPTR,A ;D/A转换 ACALL DELAY ;延时,等待转换结束 INC R0 ;正弦表位移量增量 CJNER0,#7FH,LOOP3 ;第三象限输出完?LOOP4:MOV A,@R0
4、 ;查表 CPL A ;表值取反 MOVX@DPTR,A ;D/A转换 ACALL DELAY ;延时,等待转换结束 DEC R0 ;正弦表位移量减量 CJNER0,#6DH,LOOP4 ;第四象限输出完? SJMPLOOP1DELAY:MOV R7,#200 ;延时50msDEL1:MOVR6,#123 NOPDEL2:JNZR6,DEL2 DJNZR
5、7,DEL1 RETSINTAB:DB80H,83H,86H,89H,8DH,90H,93H,96HDB99H,9CH,9FH,0A2H,0A5H,0A8H,0ABH,0AEHDB0B1H,0B4H,0B7H,0BAH,0BCH,0BFH,0C2H,0C5HDB0C7H,0CAH,0CCH,0CFH,0D1H,0D4H,0D6H,0D8HDB0DAH,0DDH,0DFH,0E1H,0E3H,0E5H,0E7H,0E9HDB0EAH,0ECH,0EEH,0EFH,0F1H,0F2H,0F4H,0F5HDB0F6H,0F7H,0F8H,0F9H,0FAH,0FBH,0FCH,0FDHDB
6、0FDH,0FEH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFHDB0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FEH,0FDHDB0FDH,0FCH,0FBH,0FAH,0F9H,0F8H,0F7H,0F6HDB0F5H,0F4H,0F2H,0F1H,0EFH,0EEH,0ECH,0EAHDB0E9H,0E7H,0E5H,0E3H,0E1H,0DEH,0DDH,0DAHDB0D8H,0D6H,0D4H,0D1H,0CFH,0CCH,0CAH,0C7HDB0C5H,0C2H,0BFH,0BCH,0BAH,0B7H,0B4H,0B1HDB0AEH,0ABH,0A
7、8H,0A5H,0A2H,9FH,9CH,99HDB96H,93H,90H,8DH,89H,86H,83H,80HDB80H,7CH,79H,78H,72H,6FH,6CH,69HDB66H,63H,60H,5DH,5AH,57H,55H,51HDB4EH,4CH,48H,45H,43H,40H,3DH,3AHDB38H,35H,33H,30H,2EH,2BH,29H,27HDB25H,22H,20H,1EH