您好,欢迎访问三七文档
当前位置:首页 > 电子/通信 > 综合/其它 > 单片机控制DAC0832输出正弦波三角波汇编程序
单片机控制DAC0832输出正弦波三角波汇编程序org0000hLJMPMAINORG0003HLJMPL0MAIN:MOVR2,#0aH;调幅倍数MOVR4,#01H;增减选择MOVR5,#01Hpp:SETBEASETBEX0;延时计数个数MOVA,#0FFH;读取波形状态MOVP1,AMOVA,P1JNBACC.0,ZXB;P1.0=0则选择正弦波JNBACC.1,SJB;P1.1=0则选择三角波JNBACC.2,FB;P1.2=0则选择方波AJMPPPZXB:MOVR1,#00HLOOP1:MOVA,R1MOVDPTR,#TABLE1;读取正弦波数据首地址MOVCA,@A+DPTR;去表格数据MOVB,R2MULAB;幅度大小INCR1XCHA,R1CLRCSUBBA,#0AH;是否已采样半个周期JNCLK1;C=0跳转,即R1大于0A,以采样半个周期以上ADDA,#0AHXCHA,R1;还原R1ADDA,#80H;8OH为零点,取得正的幅度值AJMPLK0LK1:ADDA,#0AHXCHA,R1MOVR3,AMOVA,#80HCLRCSUBBA,R3;80H为零点,取得负的幅度值LK0:MOVDPTR,#8000H;送DA转换入口地址MOVX@DPTR,AMOVA,R5KD:DECR5;调用延时CALLDELAYCJNER5,#00H,KDMOVR5,ACJNER1,#12H,LOOP1LJMPPPFB:MOVR1,#00HLOOP2:MOVA,R1MOVDPTR,#TABLE2;读取方波数据首地址MOVCA,@A+DPTR;去表格数据MOVB,R2MULAB;幅度大小INCR1XCHA,R1CLRCSUBBA,#0AH;是否已采样半个周期JNCLK3;C=0跳转,即R1大于0A,以采样半个周期以上ADDA,#0AHXCHA,R1;还原R1ADDA,#80H;8OH为零点,取得正的幅度值AJMPLK2LK3:ADDA,#0AHXCHA,R1MOVR3,AMOVA,#80HCLRCSUBBA,R3;80H为零点,取得负的幅度值LK2:MOVDPTR,#8000H;送DA转换入口地址MOVX@DPTR,AMOVA,R5KD0:DECR5;调用延时CALLDELAYCJNER5,#00H,KD0MOVR5,ACJNER1,#12H,LOOP2LJMPPPSJB:MOVR1,#00HLOOP3:MOVA,R1MOVDPTR,#TABLE3;读取三角波波数据首地址MOVCA,@A+DPTR;去表格数据MOVB,R2MULAB;幅度大小INCR1XCHA,R1CLRCSUBBA,#0DH;是否已采样半个周期JNCLK5;C=0跳转,即R1大于D,以采样半个周期以上ADDA,#0DHXCHA,R1;还原R1ADDA,#80H;8OH为零点,取得正的幅度值AJMPLK4LK5:ADDA,#0DHXCHA,R1MOVR3,AMOVA,#80HCLRCSUBBA,R3;80H为零点,取得负的幅度值LK4:MOVDPTR,#8000H;送DA转换入口地址MOVX@DPTR,AKD1:MOVA,R5DECR5;调用延时CALLDELAYCJNER5,#00H,KD1MOVR5,ACJNER1,#18H,LOOP3LJMPPPDELAY:NOPRETL0:CLREAPUSHAPUSHPSWJBP1.3,L1;中断子程序CJNER4,#00H,KL0INCR4SJMPLD0KL0:MOVR4,#00HLD0:JNBP1.3,LD0;判断键是否松开LJMPLENDL1:JBP1.4,L2MOVA,R4JNZKL1;判断幅度是增还是减CJNER2,#0AH,KK0;判断幅度是否达到最大SJMPLD1KK0:INCR2;幅度增加0.5VSJMPLD1KL1:CJNER2,#00H,KK1SJMPLD1KK1:DECR2;幅度减小0.5VLD1:JNBP1.4,LD1LJMPLENDL2:JBP1.5,LENDMOVA,R4JNZKL2;判断频率的增减MOVA,#05H;每次周期变化20微秒CLRCADDA,R5JCLD2MOVR5,ALJMPLD2KL2:MOVA,R5CLRCSUBBA,#05HJCLD2MOVR5,ALD2:JNBP1.5,LD2LEND:POPPSWPOPASETBEARETITABLE1:DB00H,04H,08H,0bH,0cH,0cH,0bH,08H,04H,00H,04H,08H,0bH,0cH,0cH,0bH,08H,04HTABLE2:DB00H,00H,00H,00H,00H,00H,00H,00H,00H,0CH,0CH,0CH,0CH,0CH,0CH,0CH,0CH,0CHTABLE3:DB00H,02H,04H,06H,08H,0AH,0CH,0AH,08H,06H,04H,02H,00H,02H,04H,06H,08H,0AH,0CH,0AH,08H,06H,04H,02H
本文标题:单片机控制DAC0832输出正弦波三角波汇编程序
链接地址:https://www.777doc.com/doc-6064479 .html