资源描述:
《测控电路-程序.doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、当R1=R2=R3=R时,反向锯齿波程序清单:MOVDPRT,#0DFFFHDA1:MOVR6,#80HDA2:MOVA,R6MOVX@DPTR,ADJNZR6,DA2AJMPDA1正向锯齿波程序清单:MOVDPRT,#0DFFFHDA1:MOVR6,#80HDA2:MOVA,R6MOVX@DPTR,AINCR6CJNER6,#0FFH,DA2AJMPDA1双向锯齿波程序清单:MOVDPRT,#0DFFFHMOVR6,#00HDA1:MOVA,R6MOVX@DPTR,AINCR6AJMPDA1单路正弦波电压输出(一个周期的正弦量化数据放在80H为首地址的表格中)MOV
2、R5,#00HSIN:MOVA,R5MOVDPTR,#TABMOVCA,@A+DPTRMOVDPTR,#0DFFFHMOVX@DPTR,AINCR5AJMPSINTAB:DB80两路正弦移相信号输出MOVR5,#00HMOVR1,#40HSIN:MOVA,R5MOVDPTR,#TABMOVCA,@A+DPTRMOVDPTR,#0DFFFHMOVX@DPTR,AINCR5MOVA,R1MOVDPTR,#TABMOVA,@A+DPTRMOVDPTR,#0BFFFHMOVX@DPTR,AINCR1AJMPSINADC0809与单片机的接口设计图例:1.对8路模拟信号轮流采样
3、一次,并依次把转换结果存储到片内RAM以DATA为起始地址的连续单元中。MAIN:MOVR1,#DATA;MOVDPTR,#7FF8H ;MOVR7,#08H ;LOOP:MOVX@DPTR,A ;(插入延时等待tEOC)HER:JBP3.3,HER;MOVXA,@DPTR ;MOV@R1,A ;INCDPTR ;INCR1 ;DJNZR7,LOOP ;2.读取IN0通道的模拟量转换结果,并送至片内RAM以DATA为首地址的连续单元中。ORG0013H ;AJMPPINT1 ORG2000HMAIN:MOVR1,#
4、DATA;SETBIT1 ;SETBEA ;SETBEX1 ;MOVDPTR,#7FF8H ;MOVX@DPTR,A ;LOOP:NOP ;AJMPLOOPORG2100H ;PINT1:PUSHPSW ;PUSHACCPUSHDPLPUSHDPHMOVDPTR,#7FF8HMOVXA,@DPTR ;MOV@R1,A ;INCR1 ;MOVX@DPTR,A ;POPDPH ;POPDPLPOPACCPOPPSWRETI;温度传感器设计程序voidmain(void){inttemperature;W
5、DTCN=0xde;WDTCN=0xad;SYSCLK_Init();PORT_Init();UART0_Init();ADC0_Init();while(1){AD0INT=0;AD0BUSY=1;while(AD0INT==0);temperature=ADC0;temperature=temperature-2649;temperature=temperature/9.762;TI0=0;SBUF0=temperature;while(!TI0);}系统时钟初始化voidSYSCLK_Init(void){inti;OSCXCN=0x67;for(i=0;i<2
6、56;i++);while(!(OSCXCN&0x80));OSCICN=0x88;丢失时钟检测器IO口初始化voidPORT_Init(void){XBR0=0x04;XBR1=0x00;XBR2=0x40;P0MDOUT
7、=0x01;}UART0初始化voidUART0_Init(void){SCON0=0x50;TMOD=0x20;TH1=(SYSCLK/BAUDRATE/16);TR1=1;CKCON
8、=0x10;PCON
9、=0x80;}ADC0初始化voidADC0_Init(void){ADC0CN=0x80;REF0CN=0x07;AMX0SL=0x0f
10、;ADC0CF=(SYSCLK/2500000)<<3;ADC0CF
11、=0x01;EIE2&=~0x02;EIE1&=~0x04;7.消抖:p2:process(f_glrn,bstart,fosc)beginiff_glrn='0'thenf_start<='1';start_count<="0000";elsiffosc'eventandfosc='1'thenifbstart='0'andstart_count(3)='0'andf_start='1'thenstart_count<=start_count+1;elsifbstart='0'a