DSP

DSP TMS320C5509A 控制DDS AD9854芯片进行PSK相位调制

2019-07-13 20:48发布

接上一节https://blog.csdn.net/pxy198831/article/details/86738839DSP TMS320C5509A 控制DDS AD9854芯片驱动 AD9854有相位寄存器,不设置的话输出的两位就按照0~360°连续变化, PSK调制相位是越变的,以8PSK为例 每一种相位表示一个八进制的数据,每45°为一种情况 程序如下: interrupt void dmaCh0Isr(void) { int I_Q_result; int PSK8[16] = {1,3,2,6,7,5,4,0,0,4,5,7,6,2,3,1}; int ATW; static int noise_flag = 0,i=0; unsigned char AM_H,AM_L; static int fase=0; //Read the DMA status register to clear it so new interrupts will be seen DMA_RGETH(hDMACH0,DMACSR); DMA_start(hDMACH0); /* Begin Transfer */ if (dds_flag == 1) { // I_Q_result = dstPing[0]; //直接出音频 I_Q_result = AGC_audio(dstPing[0]); fir((DATA *)&I_Q_result, (DATA *)B_BS,(DATA *)&I_Q_result, BS_dbuf,1,BL_BS); // audio_DDS[Index] += 32768; // I_Q_result = 2*A*((float)I_Q_result)/(1+A); if (I_Q_result > 0) { I_Q_result = ((float)I_Q_result)/8192*2048; } if (I_Q_result < 0) { I_Q_result = ((float)I_Q_result)/8192*2048; } // dc = 2048; // dc = ((1-A)*0x3fff)/(1+A); // ac = (2*A*I_Q_result)/(1+A); ATW = (2*A*I_Q_result)/(1+A) + 2048; // temp = ATW; // ATW = (temp/65536)*4096; AM_H = (ATW&0x0f00)>>8; AM_L = ATW&0xff; audio_DDS[Index] = (AM_H<<8)|AM_L; if(Index>=200) { Index = 0; } if (audio_DDS[Index++] > 1000) { if (noise_flag<200) { noise_flag++; } } else { noise_flag = 0; } if (noise_flag != 200) { // AD9854_WR_Byte(OSK_I1_ADDRESS,AM_H); //设置I通道幅度 // AD9854_WR_Byte(OSK_I2_ADDRESS,AM_L); } else { // AD9854_WR_Byte(OSK_I1_ADDRESS,0xff); //设置I通道幅度 // AD9854_WR_Byte(OSK_I2_ADDRESS,0xff); } // ad9854_update(); // rear++; if(i++==0) { AD9854_WR_Byte(0,0x00); //设置 AD9854_WR_Byte(1,0x00); AD9854_WR_Byte(2,0x00); //设置 AD9854_WR_Byte(3,0x00); ad9854_update(); } if(PSK8[i-1]==0) { fase+=0x08; } else if(PSK8[i-1]==1) { fase+=0x10; } else if(PSK8[i-1]==2) { fase+=0x20; } else if(PSK8[i-1]==3) { fase+=0x18; } else if(PSK8[i-1]==4) { fase+=0; } else if(PSK8[i-1]==5) { fase+=0x38; } else if(PSK8[i-1]==6) { fase+=0x28; } else if(PSK8[i-1]==7) { fase+=0x30; } fase=fase%0x40; AD9854_WR_Byte(0,fase); //设置 AD9854_WR_Byte(1,0x00); AD9854_WR_Byte(2,fase); //设置 AD9854_WR_Byte(3,0x00); ad9854_update(); if(i==16) { i=1; } /* if(PSK8[i]==0) { AD9854_WR_Byte(0,0x08); //设置 AD9854_WR_Byte(1,0x00); AD9854_WR_Byte(2,0x08); //设置 AD9854_WR_Byte(3,0x00); ad9854_update(); } else if(PSK8[i]==1) { AD9854_WR_Byte(0,0x10); //设置 AD9854_WR_Byte(1,0x00); AD9854_WR_Byte(2,0x10); //设置 AD9854_WR_Byte(3,0x00); ad9854_update(); } else if(PSK8[i]==2) { AD9854_WR_Byte(0,0x20); //设置 AD9854_WR_Byte(1,0x00); AD9854_WR_Byte(2,0x20); //设置 AD9854_WR_Byte(3,0x00); ad9854_update(); } else if(PSK8[i]==3) { AD9854_WR_Byte(0,0x18); //设置 AD9854_WR_Byte(1,0x00); AD9854_WR_Byte(2,0x18); //设置 AD9854_WR_Byte(3,0x00); ad9854_update(); } else if(PSK8[i]==4) { AD9854_WR_Byte(0,0x00); //设置 AD9854_WR_Byte(1,0x00); AD9854_WR_Byte(2,0x00); //设置 AD9854_WR_Byte(3,0x00); ad9854_update(); } else if(PSK8[i]==5) { AD9854_WR_Byte(0,0x38); //设置 AD9854_WR_Byte(1,0x00); AD9854_WR_Byte(2,0x38); //设置 AD9854_WR_Byte(3,0x00); ad9854_update(); } else if(PSK8[i]==6) { AD9854_WR_Byte(0,0x28); //设置 AD9854_WR_Byte(1,0x00); AD9854_WR_Byte(2,0x28); //设置 AD9854_WR_Byte(3,0x00); ad9854_update(); } else if(PSK8[i]==7) { AD9854_WR_Byte(0,0x30); //设置 AD9854_WR_Byte(1,0x00); AD9854_WR_Byte(2,0x30); //设置 AD9854_WR_Byte(3,0x00); ad9854_update(); } i++; if(i==7) { i=0; } */ } }