電力系統(tǒng)中多通道同步采樣ADC(AD7606)與浮點(diǎn)DSP(ADSP-21479)通信的設(shè)計(jì)與實(shí)現(xiàn)
4.測(cè)試結(jié)果和結(jié)論
DSP軟件設(shè)置50K的采樣信號(hào),對(duì)8個(gè)通道的數(shù)據(jù)進(jìn)行同時(shí)采樣。各模擬通道輸入信號(hào)分別為:通道5連接1KHz正弦波,其余通道接地。
4.1 測(cè)試結(jié)果
1) 利用VDSP5.0++ 的plot窗口(VDSP->View->Debug Windows->Plot)觀察5通道數(shù)據(jù),
1. 通道5提取到1KHz正弦波;
4.2 結(jié)論
這種連接方式只使用DSP的一個(gè)串行SPORT口即可同時(shí)讀取8路ADC的數(shù)據(jù)。但由于8路數(shù)據(jù)都通過一路數(shù)據(jù)輸出給DSP,而AD7606支持的最高串行時(shí)鐘頻率有限,模數(shù)轉(zhuǎn)換還要占用一部分采樣周期,因此串行輸出的連接下,AD7606不能工作在最高200KSPS采樣率下。
根據(jù)AD7606數(shù)據(jù)手冊(cè),AD7606的SCLK上限為23.5MHz。FLAG信號(hào)驅(qū)動(dòng)CONVST A/B信號(hào),單路串行輸出八通道數(shù)據(jù)。不考慮轉(zhuǎn)換時(shí)間最高采樣率可達(dá)23500000/(16×8)=183.5kHz,由于每個(gè)周期數(shù)據(jù)轉(zhuǎn)換將消耗一定時(shí)間,所以實(shí)際無法達(dá)到此速度。假設(shè)采樣周期用Tconvst表示,根據(jù)AD7606數(shù)據(jù)手冊(cè),模數(shù)轉(zhuǎn)換時(shí)間為3.45us,所以 Tconvst-3.45us代表采樣周期中傳輸數(shù)據(jù)的時(shí)間。八通道總數(shù)據(jù)量為128個(gè)時(shí)鐘周期,所以(Tconvst-3)/128近似為每bit數(shù)據(jù)的時(shí)鐘周期。由于SCLK最大為23.5MHz,據(jù)此可以推算出此模式下最高采樣頻率:
(Tconvst(max)-3.45)/128 = 1/23.5
Tconvst(max)≈8.89us
即最高采樣率為1/ Tconvst(max) = 112KSPS
同理可知,若采用兩口同時(shí)輸出轉(zhuǎn)換數(shù)據(jù),即啟動(dòng)2個(gè)SPORT分別讀取8個(gè)通道的數(shù)據(jù),實(shí)際最高采樣率能達(dá)到161K SPS。
當(dāng)AD7606采用并行方式輸出到DSP時(shí),即可得到最高200KSPS采樣率。
5.DSP參考代碼
1.配置SRU
// This function will setup the SRU Registers
void InitSRU(void)
{
//Generating Code for connecting : SPORT0_CLK to DAI_PIN1
SRU (HIGH, PBEN01_I);
SRU (SPORT0_CLK_O, DAI_PB01_I);
//Generating Code for connecting : SPORT0_FS to DAI_PIN4
SRU (HIGH, PBEN04_I);
SRU (SPORT0_FS_O, DAI_PB04_I);
//Generating Code for connecting : DAI_PIN5 to SPORT0_DA
SRU (LOW, PBEN05_I);
SRU (DAI_PB05_O, SPORT0_DA_I);
//Generating Code for connecting : FLAG4 to DPI_PIN1
SRU (HIGH, DPI_PBEN01_I);
SRU (FLAG4_O, DPI_PB01_I);
//Generating Code for connecting : FLAG5 to DPI_PIN2
SRU (HIGH, DPI_PBEN02_I);
SRU (FLAG5_O, DPI_PB02_I);
}
2.IRQ1 BUSY中斷服務(wù)程序
void AD7606_BUSY_IRQs(int sig_int)
{
busy++;
interrupt(SIG_SP0,Count_SPORT0_RX_IRQs);
#ifdef DMA
* (volatile int *)SPCTL0 =( SPEN_A | SLEN32 | ICLK | IFS | LAFS | SDEN_A | FSR | DITFS| LFS );
#endif
#ifdef CORE
* (volatile int *) SPCTL0 =( SLEN16 | ICLK | IFS | FSR | LAFS | LFS | DITFS);
*(volatile int *) SPCTL0 |=SPEN_A ;
#endif
}
3.SPORT初始化程序
void init_sport(){
* (volatile int *) SPCTL0 = 0;
* (volatile int *) SPCTL1 = 0;
* (volatile int *) SPMCTL0 = 0;
* (volatile int *) SPMCTL1 = 0;
SPORT_DMA_setup:
* (volatile int *) IISP0A =(int)rx_buf0a ;
* (volatile int *) IMSP0A = 1;
* (volatile int *) CSP0A = CHNUM;
//configure the sport
/* */
/* CLKDIV0=[fCCLK(266 MHz)/4xFSCLK(17 MHz)]-1 = 0x0005 */
/* FSDIV0=[FSCLK(10 MHz)/TFS(2 MHz)]-1 = 31 = 0x001F */
//13m hz1m 0x00080003;
/* Configure SPORT0 as a reciever (Rx) */
* (volatile int *) DIV0 = 0x001F0005;
}
4.SPORT 中斷程序
void Count_SPORT0_RX_IRQs(int sig_int)
{
SP0I_counter++;
#ifdef CORE
rx_buf0a[(SP0I_counter-1)*CHNUM]=(short)(*pRXSP0A);
#endif
* (volatile int *) SPCTL0 =0;
finished=1;
#ifdef DMA
if(SP0I_counter==1024){
* (volatile int *) IISP0A =(int)rx_buf0a ;
SP0I_counter=0;
}
else
* (volatile int *) IISP0A =(int)(rx_buf0a+ (SP0I_counter)*CHNUM);
* (volatile int *) IMSP0A = 1;
* (volatile int *) CSP0A = CHNUM;
#endif
interrupt(SIG_SP0,SIG_IGN);
}
數(shù)字通信相關(guān)文章:數(shù)字通信原理
評(píng)論