outportb(0x23b,0x03); /*set 8253 timer into writing mode word state*/
outportb(0x23f,0x36); /*set 0 channel working with mode 3*/
outportb(0x23f,0x74); /*set 1 channel working with mode 2*/
outportb(0x23b,0x00); /*set to write data to 0 Channel mode */
outportb(0x23f,0x02); /*write low data to 0 channel*/
outportb(0x23f,0x00); /*write high data to 0 channel*/
outportb(0x23b,0x01); /*set to write data to 1 channel*/
outportb(0x23f,LC1); /*write low data to 1 channel*/
outportb(0x23f,HC1); /*write high data to 1 channel*/
outportb(0x23b,0x0c); /*啟動(dòng)CH0,CH1工作*/
其中采樣頻率決寫入計(jì)數(shù)器1的計(jì)數(shù)值。
2.4 DMA方式下PC主機(jī)中8237A DMA控制器編程
8237A DMA控制器具有4個(gè)DMA通道,該接口電路使用通道1。
outportb(0x0x,0x05); /*mask DMA channel 1*/
outportb(0x0c,0x00); /*clear byet pointer flip*/
outportb(0x0b,0x55); /*write mode word.demand mode,address tincrease,autoinitialization,write trasfer and select 1*/
outportb(0x83,SEG); /*write page number*/
outportb(0x02,LA); /*write low 8 bit address*/
outportb(0x02,HA); /*write hige 8 bit address*/
outportb(0x03,LC); /*write low 8 bit count data*/
outportb(0x03,HC); /*write hige 8 bit count data*
outportb(0x03,0x01); /*clear mask bit of DMA channel*/
其中寫入11口的數(shù)值應(yīng)按照具體的工作方式來(lái)確定,寫入131口的頁(yè)地址SEG取20位絕對(duì)地址的最高4位的數(shù)值,而將低16位地址的數(shù)值寫入地址寄存器。寫基值字節(jié)計(jì)數(shù)寄存器的字節(jié)總數(shù)值應(yīng)為需要傳輸?shù)淖止?jié)數(shù)減1。
2.5 中斷服務(wù)程序的編寫以有中斷向量的裝入
void interrupt int9() /*中斷服務(wù)程序*/
{ disable();
ah5=inportb(0x23d); /*輸入高八位數(shù)據(jù)*/
outportb(0x23a,0x01); /*選擇傳輸?shù)退奈粩?shù)據(jù)*/
dl5=inportb(0x23d); /*輸入低四位數(shù)據(jù)*/
outportb(0x23a,0x00); /*選擇傳輸高8位數(shù)據(jù)并為A/D轉(zhuǎn)換作準(zhǔn)備*/
outportb(0x23c,0x00); /*A/D轉(zhuǎn)換完畢的標(biāo)志位清零*/
outportb(0x20,0x20);
enable();
}
void stall 1(void interrupt(*faddr)())
{
disable();
setvect(INT1,faddr); /*裝入中斷服務(wù)程序*/
enable();
}
本文介紹一種基于AD1674設(shè)計(jì)的接口電路,該電路具有查詢、中斷和DMA三種數(shù)據(jù)傳輸功能,同時(shí)采用8253定時(shí)脈沖或端口寫兩種A/D啟動(dòng)方式。其中DMA方式實(shí)現(xiàn)了數(shù)據(jù)的快速傳輸,而兩種A/D啟動(dòng)方式將會(huì)使采樣率的設(shè)定更加靈活。應(yīng)用本文原理設(shè)計(jì)的可插入通用PC機(jī)的數(shù)據(jù)采集板已用于我們的高頻多譜勒和到達(dá)角探測(cè)分析系統(tǒng)中,取得了滿意的效果。這些設(shè)計(jì)方法和原理在其它實(shí)際數(shù)據(jù)采集系統(tǒng)的設(shè)計(jì)過(guò)程中,也會(huì)具有重要的參考價(jià)值。
評(píng)論