用DDSAD9854產(chǎn)生各種波形程序集_第1頁
用DDSAD9854產(chǎn)生各種波形程序集_第2頁
用DDSAD9854產(chǎn)生各種波形程序集_第3頁
已閱讀5頁,還剩15頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡介

1、用DDS AD9854產(chǎn)生各種波形程序集本程序集包含以下波形的程序:正弦波,三角波,AM調(diào)制,F(xiàn)M調(diào)制,ASK調(diào)制,PSK調(diào)制,F(xiàn)SK調(diào)制最后還有一個(gè)包含 12864 液晶顯示、 7290 鍵盤控制的可以輸出 正弦波,三角波,方波(由單片機(jī)產(chǎn)生),AM調(diào)制,F(xiàn)M調(diào)制,ASK調(diào) 制和PSK調(diào)制的一個(gè)DDS函數(shù)發(fā)生器的綜合系統(tǒng)。這些程序都是本人寫的,單片機(jī)用的是 TI的msp430f247,這些 程序都經(jīng)過精心調(diào)試,并都已調(diào)試成功。希望這些程序能給需要的朋友一定的幫助。頭文件【】:#define PAR1_H 0x00;send_data('5');elseif(pow_10>

2、;=100)send_data(0x30+p2);send_data(0x30+p1);send_data('.');send_data(0x30+p0);send_data('d');send_data('B');send_data('m'); send_data(0x20);5send_data('5');elseif(pow_10>=100)send_data(0x30+p2); send_data(0x30+p1);send_data('.');send_data(0x30+p0);s

3、end_data('d');send_data('B'); send_data('m');send_data(0x20);set_xy(0,4);send_data(0xb2); / 步 send_data(0xbd);send_data(0xbd); / 進(jìn)send_data(0xf8);send_data(0xa3); / :send_data(0xba);set_xy(7,2);send_data(0x11);set_xy(3,2);#pragma vector=PORT1_VECTOR_interrupt void key_int(voi

4、d)if(!(P1IFG & BIT7)P1IFG = 0;return;ap=0;P1IFG = 0;key_press = 1;#pragma vector = USCIAB0TX_VECTOR_interrupt void I2C_RX(void)接收中斷if(IFG2 & UCB0RXIFG)key_code = UCB0RXBUF; / #pragma vector=TIMERA0_VECTOR_interrupt void Timer_A (void) if(M=3)if(ap)P3OUT &= BIT0; / Toggle ap=0;send_byte(O

5、SKI_2,0X00);send_byte(OSKI_1,0X00);elseP3OUT |= BIT0;ap=1;send_byte(OSKI_2,0XFF); send_byte(OSKI_1,0X0F);if(M=4)if(ap)ctr_out&=FBH;ap=0;elsectr_out|=FBH;ap=1;#pragma vector=ADC12_VECTOR_interrupt void adc12()if(M=1)samp=ADC12MEM0;dc=(1-A)*0XFFF/(1+A);ac=2*A*samp/(1+A);ATW=dc+ac;send_byte(OSKI_2,

6、ATW/0x100);send_byte(OSKI_1,ATW%0x100);else if(M=2)samp=ADC12MEM0;if(samp>0x7ff)am=samp-0x7ff;per=am*0x10000/0x7ff; /per-long int;scal=0x10000;while(pp3>0x0f && per>=0x600)per/=0x10;scal/=0x10;&&while(pp3<0x10per>=0x1000)per/=0x10;scal/=0x10;MPY=pp1;OP2=per;_NOP();_NOP

7、();spp1=RESLO;c=RESHI;MPY=pp2;OP2=per;_NOP();_NOP();spp2=RESLO;spp2=spp2+c;c=RESHI;MPY=pp3;OP2=per;_NOP();_NOP();spp3=RESLO;spp3=spp3+c;switch(scal)case 0x10000:spp1=spp2;spp2=spp3;spp3=0x0000;break;case0x1000:spp1=spp1/0x1000+(spp2%0x1000)*0x10;spp2=spp2/0x1000 +(spp3%0x1000)*0x10;spp3=spp3/0x1000;

8、break;case0x100:spp1=spp1/0x100+(spp2%0x100)*0x100;spp2=spp2/0x100+(s pp3%0x100)*0x100;spp3=spp3/0x100;break;case0x10:spp1=spp1/0x10+(spp2%0x10)*0x1000;spp2=spp2/0x10+(spp3 %0x10)*0x1000;spp3=spp3/0x10;send_byte(FTW1_1,ftw_1+spp1%0x100);send_byte(FTW1_2,ftw_2+spp1/0x100);send_byte(FTW1_3,ftw_3+spp2%

9、0x100);send_byte(FTW1_4,ftw_4+spp2/0x100);send_byte(FTW1_5,ftw_5+spp3%0x100);send_byte(FTW1_6,ftw_6+spp3/0x100);elseam=0x7ff-samp;per=am*0x10000/0x7ff; /per-long int;scal=0x10000;while(pp3>0x0f && per>=0x600)per/=0x10;scal/=0x10;while(pp3<0x10 &&per>=0x1000)per/=0x10;scal

10、/=0x10;MPY=pp1;OP2=per;_NOP();_NOP();spp1=RESLO;c=RESHI;MPY=pp2;OP2=per;_NOP();_NOP();spp2=RESLO;spp2=spp2+c;c=RESHI;MPY=pp3;OP2=per;_NOP();_NOP();spp3=RESLO;spp3=spp3+c;switch(scal)case 0x10000:spp1=spp2;spp2=spp3;spp3=0;break;case0x1000:spp1=spp1/0x1000+(spp2%0x1000)*0x10;spp2=spp2/0x1000 +(spp3%0

11、x1000)*0x10;spp3=spp3/0x1000;break;case0x100:spp1=spp1/0x100+(spp2%0x100)*0x100;spp2=spp2/0x100+(s pp3%0x100)*0x100;spp3=spp3/0x100;break;case0x10:spp1=spp1/0x10+(spp2%0x10)*0x1000;spp2=spp2/0x10+(spp3 %0x10)*0x1000;spp3=spp3/0x10;ftw11=0x100+ftw_1-spp1%0x100;ftw12=0x100+ftw_2-(0x01-ftw11/0x100)-spp

12、1/0x100;ftw13=0x100+ftw_3-(0x01-ftw12/0x100)-spp2%0x100;ftw14=0x100+ftw_4-(0x01-ftw13/0x100)-spp2/0x100;ftw15=0x100+ftw_5-(0x01-ftw14/0x100)-spp3%0x100;ftw16=ftw_6-(0x01-ftw15/0x100)-spp3/0x100;send_byte(FTW1_1,(uchar)ftw11);send_byte(FTW1_2,(uchar)ftw12);send_byte(FTW1_3,(uchar)ftw13);send_byte(FTW

13、1_4,(uchar)ftw14);send_byte(FTW1_5,(uchar)ftw15);send_byte(FTW1_6,(uchar)ftw16);ADC12CTL0 &= ENC;發(fā)送 1 字節(jié)數(shù)據(jù)void send_byte(uchar add,uchar data)data_dir=0xff;ctr_out|=WR;add_out=add;/送地址_NOP();ctr_out&=WR;/拉低 WRdata_out=data;/送數(shù)據(jù)_NOP();ctr_out|=WR;/拉高 WRif(fclk)ctr_out|=UDCLK;ctr_out&=UDCL

14、K;else delayus(5);fclk=1;*讀取一個(gè)字節(jié)的數(shù)據(jù)uchar read_byte(uchar add)uchar dat;data_dir=0x00;ctr_out|=RD; add_out=add; ctr_out&=RD;_NOP();dat=data_in; ctr_out|=RD; return dat;/*/void send_command(unsigned char command) Data_dir = 0x00;RS_0;RW_1;E_1;while (Data_in & 0x80);Data_dir = 0xFF;E_0;RS_0;RW_

15、0;Data_out = command;E_1;_NOP();E_0;void send_data(unsigned char data)Data_dir = 0x00;RS_0;RW_1;E_1;while (Data_in & 0x80);Data_dir = 0xFF;E_0;RS_1;RW_0;Data_out = data;E_1;_NOP();E_0;/ lcd_cou nt A= 0x01;/ if(lcd_count=1)lcd_con1con+=data;/ else lcd_x+;/*/ 設(shè)置顯示位置 xpos(116),tpos(14)/*/void set_x

16、y(unsigned char xpos,unsigned char ypos) switch(ypos)case 1: send_command(0X80|xpos);break;case 2: send_command(0X90|xpos);break;case 3: send_command(0X88|xpos);break;case 4: send_command(0X98|xpos);break;default:break; */ 在指定位置顯示字符串/*void print(unsigned char x,unsigned char y,unsigned char* str) un

17、signed char lcd_temp; set_xy(x,y);lcd_temp=*str;while(lcd_temp != 0x00) send_data(lcd_temp);lcd_temp=*(+str);寫字符串*/*/ 寫字符串子程序/xposl取07共八列,yposl取1 4共四行/*/ void printstr(unsigned char xpos,unsigned char ypos,unsigned char str,unsigned char k) unsigned char n;switch (ypos) case 1: xpos |= 0x80;break; /

18、 case 2: xpos |= 0x90;break; / case 3: xpos |= 0x88;break; / case 4: xpos |= 0x98;break; / default: break;send_command(xpos); / 存器實(shí)際地址第一行第二行第三行 第四行此處的Xpos已轉(zhuǎn)換為LCM的顯示寄for(n=0;n < k;n+)send_data(strn); /顯示漢字時(shí)注意碼值,連續(xù)兩個(gè)碼表示一個(gè)漢字*清屏 */ 清屏*void clr_lcd(void)send_command(0x01);/send_command(0x34);/send_command(0x30);*數(shù)字退格鍵*void backspace()if(lcd_count=0)if(lcd_x!=0)lcd_x-;set_xy(lcd_x,lcd_y);lcd_count=0;send_data(lcd_con1-con); send_data(0x20); lcd_x-;set_xy(lcd_x,lcd_y);lcd_count=0;send_data(lcd_con1-con);elselcd_x=7;lcd_y-;set_xy(lcd_x,lcd_y);lc

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論