多通道音頻信號處理 (DTMF decoders)

Slides:



Advertisements
Similar presentations
663 Chapter 14 Integral Transform Method Integral transform 可以表示成如下的積分式的 transform  kernel Laplace transform is one of the integral transform 本章討論的 integral.
Advertisements

國立成功大學工程科學系 Department of Engineering Science -National Cheng Kung University 控制與訊號處理實驗室 Control & Signal Processing Lab MATLAB/Simulink 教學.
Final Review Chapter 1 Discrete-time signal and system 1. 模拟信号数字化过程的原理框图 使用 ADC 变换器对连续信号进行采样的过程 使用 ADC 变换器对连续信号进行采样的过程 x(t) Analog.
1 I/O 设备访问方式和类型. 2 Overview n The two main jobs of a computer: l I/O (Input/Output) l processing n The control of devices connneted to the computer is.
第一部分 中考基础复习 第一章 声现象.
Memory Pool ACM Yanqing Peng.
資料庫設計 Database Design.
CHAP 2 Computer-System Structures 计算机系统结构
序列埠通訊.
Chapter 13 輸入/輸出系統 (I/O Systems)
Audio.
加速度計 指導老師 : 洪正瑞 製作人 : 蔡昌佑.
XI. Hilbert Huang Transform (HHT)
3-3 Modeling with Systems of DEs
CH1 Number Systems and Conversion
AN INTRODUCTION TO OFDM
IV. Implementation IV-A Method 1: Direct Implementation 以 STFT 為例
5-3 8x8矩陣LED控制實習.
Applications of Digital Signal Processing
Population proportion and sample proportion
Hardware Chen Ching-Jung
CH.2 Introduction to Microprocessor-Based Control
Chapter 5 電腦元件 目標---- 研讀完本章後,你應該可以: 閱讀有關電腦的廣告以及了解它的專業用語(行話)。
4-10 STM Timer/Counter 與比較吻合輸出
第7章 中斷系統.
Operating System Concepts 作業系統原理 Chapter 3 行程觀念 (Process Concept)
Acoustic规范和测试 Base Band 瞿雪丽 2002/1/30.
第4章 处理器(CPU) 4.1 引言 4.2 逻辑设计的一般方法 4.3 建立数据通路 4.4 一个简单的实现机制 4.5 多周期实现机制.
Chapter 5 Verilog硬體描述語言
指令集架構 計算機也跟人類一樣,需要提供一套完整的語言讓人們跟它充分溝通,以完成正確的計算工作。
5 Computer Organization (計算機組織).
·线性表的定义及ADT ·线性表的顺序存储结构 ·线性表的链接存储结构 · 单向循环链表 · 双链表、双向循环链表 · 一元多项式的加法
32位元處理器之定點數MFCC演算法的改進與探討 Improvement and Discussion of MFCC Algorithm on 32-bit Fixed-point Processors 學生:陳奕宏 指導教授:張智星.
Operating System Internals and Design principles
第4章 网络互联与广域网 4.1 网络互联概述 4.2 网络互联设备 4.3 广域网 4.4 ISDN 4.5 DDN
Chapter 3 行程觀念 (Process Concept)
微程序控制器 刘鹏 Dept. ISEE Zhejiang University
Short Version : 6. Work, Energy & Power 短版: 6. 功,能和功率
無線通訊系統模擬 姓名:顏得洋 學號:B
专题 DSP McBSP设计 制作:DSP技术中心 主讲:李玉柏
微算機(二) 's UART mode0 input
聲轉電信號.
内容提要:
第14章 其它DSP设计库 14.1 总线控制库 14.2 复数信号库 14.3 Gates库 14.4 状态机函数库
第4讲 传输层之二 本讲目的: 本讲概述: Internet传输层的实现和实例 面向连接的传输: TCP TCP拥塞控制 拥塞控制原则
VI. Brief Introduction for Acoustics
‘C54x寻址方式 ‘C54x特殊寻址方式说明 ‘C54x指令集 ‘C54x特殊指令使用说明
Labview內部Linx功能簡介(Analog/Digital/PWM)
重點 資料結構之選定會影響演算法 選擇對的資料結構讓您上天堂 程式.
陳慶瀚 機器智慧與自動化技術(MIAT)實驗室 國立中央大學資工系 2013年5月28日
第6章 FIR数字滤波器设计 6.1 FIR数字滤波器原理 6.2 使用DSP Builder设计FIR数字滤波器
第3章 認識處理元.
6.1 输入/输出 6.2 CPU与外设数据传送方式 6. 3 MCS-51中断系统 6. 4 中断应用举例
第6章: 数字输入/输出模块(I/O) 6.1 数字I/O端口概述 6.2 数字I/O端口寄存器 6.3 I/O端口应用.
組合語言和程式範例.
自动变速器 概况 所有车型采用了6速带多模式控制超级ECT(电子控制自动变速器) 基本操作和结构与 LS430 (UCF30)相同
通訊實驗 實驗三 遙控車程式流程圖 姓名:顏得洋 學號:B
5-6 串列埠模式0輸出埠擴充實習.
中国科学技术大学计算机系 陈香兰 2013Fall 第七讲 存储器管理 中国科学技术大学计算机系 陈香兰 2013Fall.
通訊實驗 實驗三 遙控車程式流程圖 姓名:顏得洋 學號:B
第九章 BIOS和DOS中断 在存储器系统中,从地址0FE000H开始的8K ROM(只读存储器)中装有BIOS(Basic Iuput /output System)例行程序。驻留在ROM中的BIOS给PC系列的不同微处理器提供了兼容的系统加电自检,引导装入,主要I/O设备的处理程序以及接口控制等功能模块来处理所有的系统中断。使用BIOS功能调用,给程序员编程带来很大方便,程序员不必了解硬件操作的具体细节,直接用指令设置参数,然后中断调用BIOS中的子功能,所以利用BIOS功能编写的程序简洁,可读性好,
第3章 TMS320LF240 x的CPU功能模块和时钟模块
WIRELESS LAN B 邱培哲 B 張宏安.
第10章 存储器接口 罗文坚 中国科大 计算机学院
第六章 記憶體.
实验2 中断模拟实验.
2 Number Systems, Operations, and Codes
FPPA 程式設計 這一章開始正式進入FPPA程式設計的世界,我會從一個簡單的程式開始解說,一邊介紹專案開發時最常應用的技巧還有程式控制的手段,一邊把系統規畫的概念導入給大家,讓大家對專案的規畫能有一個初步的概念。
通訊實驗 實驗三 遙控車程式流程圖 姓名:顏得洋 學號:B
测试功能 目录 页 程序的状态监视功能 ……………... 2 程序状态监视的模式 …………………………. 3
Presentation transcript:

多通道音頻信號處理 (DTMF decoders) 指導教授:蔡亮宙老師 簡聰富老師 學 生:劉念宗 中華民國 九十 年 九 月 十二 日

主題架構 數位振盪器(Digital Oscillators) Goertzel’s algorithm (演算法) Interrupt(中斷)之資料結構與應用

數位振盪器原理推導 利用正弦波 sin x 的指數形式 : 可以得到正弦序列 : 的 z 轉換 設系統的轉移函數 H(z) = Y(z)/X(z) 就是正弦序列 sinkwT的 z 轉換,即

Digital Oscillators(數位振盪器) Digital Sinusoidal Oscillators :  H(z) = [b0*z^(-1)]/[1+a1*z^(-1)+a2*z^(-2)] -----(1) where b0 = Asin(w0) a1 = -2*cos(w0) a2 = 1 w0= 2πfi/fs ;fs:sampling frequency  H(z) = [Asin(w0)*z^(-1)]/[1-2*cos(w0)*z^(-1)+z^(-2)]  P1,2 = [cos(w0)+j sin(w0)],[cos(w0)-j sin(w0)] = 1∠w0

探討Digital Oscillators 與 DTMF decoders P1,2是一對複數根,其振幅值為1,Phase為w0。振幅值為1的極點對應一個數位振盪器,其頻率由係數b0,a1和a2來決定 。 b0 = Asin(w0) -1 1 a1 = -2*cos(w0) z-plane a2 = 1 因此,設計一個振盪器,主要在於確定這些係數

H(z) = [b0*z^(-1)]/[1+a1*z^(-1)+a2*z^(-2)] -----(1) 由上式(1) : H(z) = [b0*z^(-1)]/[1+a1*z^(-1)+a2*z^(-2)] -----(1) 可得: Y(z)+a1*z^(-1)*Y(z)+a2*z^(-2)*Y(z) = b0*z^(-1)*X(z)  y[n]+a1*y[n-1]+a2*y[n-2] = b0*x[n-1] 或是  y[n] = -a1*y[n-1]-a2*y[n-2]+b0*x[n-1] -------------(2) 上列(2)式,是一個二階差分方程式。 而DTMF decoder 方程式為: Y(n)= X(n)+2cos(coef)×Y(n-1)+(-1)Y(n-2) ---------(3) where coef =360×frequency/sample rate X(n) is the current sample value. Y(n-1) and Y(n-2) are feedback storage elements

where coef= 2πfi/fs ; fs:sampling frequency 將上式(2) ---數位振盪器的差分方程式與 上式(3) ---DTMF decoder方程式互相比對,此時 b0 = 1 a1 = -2*cos(coef) a2 = 1 where coef= 2πfi/fs ; fs:sampling frequency 令H(z)的分母[z^2-2*cos(coef)*z+1]=0,求得: P1,2= [cos(coef)+j sin(coef)],[cos(coef)-j sin(coef)] = 1∠coef 可以明確的知道:DTMF的行(高頻),列(低頻)等八個 頻率之組合是由數位振盪器來提供的。

再者,DTMF tone 並非只產生頻率,工作時間間隔 也必須指明。根據AT&T的規格說明,對於按鍵式 撥號電話而言,信號的最大傳輸速率必須為 10digits/sec(或100msec/digit)。 因此,a sample-store interval takes approximately 25 ms. 並且為了解決32 channels在DFT processing時,無法儲 存時間(save time)而使得資料遺失(data loss)的問題 使用Buffer來儲存要傳送給DFT處理的輸入資料流 (input stream)。

The buffer uses four levels to store the input data during a 100msec interval. Buffer Size = N 4 levels = 32 K words where the number of samples, N, is 200 ~ 256.

Goertzel’s algorithm (演算法) X(n) Vk(n) Y(n,k,N) 2×cos(2πk/N) - exp(-j2×π×k/N) -1 <Goertzel’s algorithm(演算法)應用於二階IIR濾波器的結構圖> + + Z^(-1) + Z^(-1)

解析運用在DTMF的Goertzel’s algorithm The DTMF frequency is transformed to a discrete fourier transform (DFT) coefficient. The relationship between the DTMF frequency (fi) and the DFT coefficient (k) is : k = N×fi/fs where fs = Sampling frequency N = Filter length For each k, the state variable, Vk(n) is: Vk(n) = 2×cos(2×π×k/N)×Vk(n-1)-Vk(n-2)+X(n) where n = 0,1,---,N Thereafter, the output, Y(n,k,N) is: Y(n,k,N) = Vk(N)- exp(-j2×π×k/N) ×Vk(N-1)

Goertzel’s algorithm與DTMF之能量 轉換 The DTMF frequency at which the incoming signal has maximum energy is the detected frequency. This energy calculation is : 經Goertzel’s algorithm運算後的頻譜 |Y(n,k,N)|^2 = Vk(N)^2+Vk(N-1)^2 –2*cos(2πk/N)* Vk(N)^2*Vk(N-1)^2

DTMF decoders與Goertzel’s algorithm (1).使用Goertzel’s演算法執行離散傅立葉轉換(discrete Fourier transform ,DFT)。 每個頻率只需要一個實數係數就可以決定數值的 振幅。 (2).Goertzel’s algorithm只要獲得任何取樣就可以立刻處 理,不必全數獲得取樣之後才進行處理。 (3).Goertzel’s algorithm運用於DTMF解碼上是非常適合 的,其優點為: A.步驟少、執行速度快。 B.所需常數較少,可節省記憶體空間。 DTMF decoders與Goertzel’s algorithm

Y(n)= X(n)+2cos(coef)×Y(n-1)+(-1)Y(n-2) (4) The DTMF decoder equation is: Y(n)= X(n)+2cos(coef)×Y(n-1)+(-1)Y(n-2) where coef =360×frequency/sample rate X(n) is the current sample value. Y(n-1) and Y(n-2) are feedback storage elements for the frequency point ,k. The value of k is : k = N × Freq/(Sample Rate) The decoder equation uses the initial data : Y(-1) = 0, Y(-2) = 0, Y(-3) = 0,…for n =0,1,2,…,n-1 The sample rate is 8 KHz.

<Tone Decoder ---16 DFT Transforms >

<Modified DTMF Tone Decoder >

系統流程圖 No Yes No Yes Yes Find Max Channel No Initialize Below Threshold Initialize Signal Strength? Above Threshold Pointer to Next 2 Channels Below Threshold Relative Peak? Above Threshold Get Channel Samples and Store to Buffer Channel row.4 DFTs and Find Max Channel Row Energy No Channel Column 4 DFTs Twist & Level Yes No Nth Sample of DFT Channel-2nd Harmonic DFT of Max Column and Max Row Yes Yes Find Max Channel Column Energy 2nd Harmonic Signal too Strong? No

to Pointer to Next 2 Channels 系統流程圖(續) to Pointer to Next 2 Channels to Find Max Channel Column Energy No Same as 2nd to Last Digit? Yes No No Same as Last Digit Yes Valid Tone Output No Channel Finished? Yes

System Implementation RecvInt4 Main Program (主程式) INT2 ISR ,turn on IMR Recv int No Overflow? Yes RecvInt5 RecvInt Cout0Flg(= -1時,205點收到) RecvInt6 PQueFlg(Recv int use Nth queue block buffer) No Overflow? PProcFlg(n)(Block(n)資料 已經填滿時 = -1) Yes RecvInt7

Interrupt Set up the ISR vector INT2 INT2 ISR ( Frame 0 INT10 ) INT11 Receive int subroutine RecvInt RecvInt4 RecvInt5 RecvInt6 RecvInt7

Set up the ISR vector .sect "vectors" b Main b Int1 ;02 INT1 interrupt b Int2 ;04 INT2 interrupt(Frame 0) b Int3 ;06 INT3 interrupt .space 2 * 16 ;08 TINT interrupt  Rint: b RecvInt ;0A Serial port receive interrupt RI XInt: b TransInt ;0C Serial port transmit interrupt X TRnt: b TRecvInt ;0E TDM receive interrupt TXnt: b TTransInt ;10 TDM transmit interrupt .space 18 * 16 ;12

Ch0 Ch1 Ch2 Ch3 F0 32 Channel 125us 8kHz Tchannel = 125us/32 = 3.9 us

INT2 ISR ( Frame 0 ) Int2: ;turn on IMR Recv int ;FilCout(取205點)/=0,執行Int10 ;Cout0Flg /=0,執行Int11 ;否則,read DRR data Int10: ;FilCout – 1 ;set ar5CoefBase3c,ar6F32Ch0 ; ar4PQue(B1QueCh0) & PQue+1 CoefBase3c,ar6F32Ch0, ar4PQue(B1QueCh0) & PQue+1

;caculate Filter result Block address ;Block move F11Ch31 BnF11Ch31 Int11: ;stop Recv Int ;caculate Filter result Block address ;Block move F11Ch31 BnF11Ch31 ;以ar5指向Block(n)(第n個Block) ;Clear F11Ch31~F32Ch0 ;set Block(0 ~ 3)資料填滿時PProcFlg(n) = -1 ;set Block number(0 ~ 3),並以PQueFlg表示 ;caculate PQue address

Int2: ldp #FilCout ;#FilCout=#205 lmmr IMR,#D16h ;turn on IMR Recv int, lacc FilCout,0 ;FilCout =?0 bcnd Int10,neq lacc Cout0Flg ;Cout0Flg complement cmpl sacl Cout0Flg bcnd Int11,neq lamm DRR ;read DRR data lacc #205

INT10 INT10: sub One ;FilCout - 1 sacl FilCout,0 lar ar5,#CoefBase3c ;set Ar5 - Ar6 lar ar6,#F32Ch0 lar ar4,PQue ;set ar4 = PQue & PQue + 1 lacc PQue add One sacl PQue rete

Int11 ;stop Recv Int ;caculate Filter result Block addr ;Block move F11Ch31 BnF11Ch31 ;Clear F11Ch31 ~ F32Ch0 ;set PProcFlg(n) = -1,即表示Block資料已填滿 ;caculate PQue addr

Int11 Int11: lmmr IMR,#D06h ;stop Recv Int,RINT=0 ;Stop Recv Int ;caculate Filter result Block addr lt PQueFlg ;(PQueFlg)TREG0 ;PQueFlg:Block number mpy #192 ;(TREG0)*#192PREG pac ;(PREG)ACC adds PB1F11Ch31 ;(ACC)+(PB1F11Ch31) ;B1F11Ch31ACC sacl TempInt ;16 LSBs of (ACC)TempInt ;TempInt=[(PQueFlg)*#192+B1F11Ch31]

mar *,ar5 ;Block move F11Ch31 BnF11Ch31 lar ar5,TempInt ;ar5負責做選取4個Block的哪一個 ;Block(Bn) rpt #191 ;#191RPTC,6*32=192 bldd #F11Ch31,*+ lar ar5,#F11Ch31 ;Clear F11Ch31 ~ F32Ch0 zap ;0ACC,0PREG rpt #191 sacl *+ lacc PQueFlg ;set PProcFlg(n) = -1 ;表示由ar5選取到的Block資料已經完 ;全填完 adds PPProcFlg0 sacl TempInt

lacc PQueFlg ;PQueFlg+1 & #3 PQueFlg add One and Three ;Block number lar ar5,TempInt zap ;0ACC,0PREG sub One sacl * lacc PQueFlg ;PQueFlg+1 & #3 PQueFlg add One and Three ;Block number ;(Bn0~3,總共4個Block) sacl PQueFlg

;caculus PQue addr lt PQueFlg ;(PQueFlg)TREG0 mpy #205*32 ;(TREG0)*#205*32PREG pac ;PREGACC ;(ACC)=[(PQueFlg)*#205*32] adds PB1QueCh0 ;(ACC)+(PB1QueCh0) ;B1QueCh0ACC sacl PQue ;16 LSBs of (ACC)PQue rete

lmmr IMR,#D16h (1)lmmr : Load Memory-Mapped Register (1) (2) (3) (1)lmmr : Load Memory-Mapped Register Syntax Direct: [label] lmmr dma,#addr Indirect: [label] lmmr {ind},#addr [,next ARP]

(src,addressed by PFC)(dst,specified by lower 承上(1)lmmr Execution PFC  MCS (PC)+2  PC 1k  PFC While (repeat counter/=0): (src,addressed by PFC)(dst,specified by lower 7 bits of dma) (PFC)+1  PFC (repeat counter)-1 repeat counter MCS  PFC

(2)IMR: Interrupt Mask Register A 16-bit memory-mapped register used to mask interrupts. 15 9 8 7 6 5 4 3 2 1 0 (3)#D16h :以D16h為位址,其內容值為 16h = 0000 0001 0110(2) RINT=1,start Recv Int Reserved /INT4 TXNT TRNT XINT RINT TINT /INT3 /INT2 /INT1

lamm DRR (1)lamm : Load Accumulator With Memory - Mapped Register (1) (2) (1)lamm : Load Accumulator With Memory - Mapped Register Syntax Direct: [label] lamm dma Indirect: [label] lamm {ind} [,next ARP] Execution (PC)+1  PC (dma)  ACC , Not affected by SXM

(2)DRR : Data Receive Register

Burst Mode Serial Port Receive Operation

Burst Mode Serial Port Receive Operation & 16 bits 資料傳送/接收的必備條件 (1).If FSM=1 ,every transfer and the mode is referred to as burst mode. (2).If FO=0,data is transmitted and/or received as 16- bits words. (3).在主程式(Main Program)中的Initialization: splk #00c8h,SPC;定義SPC中FSM=1,FO=0

PQue( B1QueCh0 ~ B1QueCh31) 特寫

;Receive int subroutine ;Processing 2 channels in single Interrupt RecvInt: ;DRR u_law Expanding ;(1).(DRR)ACCL(Ch1 Ch0) ;(2).取出Ch0(低8Bits) ;(3).經查表(u_Tab)解壓縮後 ; 存入B1QueCh0~B1QueCh31

RecvInt4 (2)計算X(n)+(-1)*Y(n-2) (3)計算cos(coef)*Y(n-1) ;Y(n)=X(n)+2*cos(coef)*Y(n-1)+(-1)*Y(n-2) ; (ar4) (1)計算Column係數 ;(4)計算X(n)-Y(n-2)+cos(coef)*Y(n-1) ;(5)再計算X(n)+2*cos(coef)*Y(n-1)+(-1)*Y(n-2) ;4 frequency IIR ;ar4PQue(B1QueCh0 ~ B1QueCh31;X(n)) ;ar5CoefBase3c,2c,1c(cos(coef)) ;ar6F32Ch0(Y(n-2)),F31Ch0(Y(n-1))

RecvInt5: ;Get high byte data RecvInt6: ;4 frequency IIR of 2nd channel

Receive Interrupt RecvInt: ldp #TempInt lamm DRR sacl TempInt mar *,ar4 ;*ar4:PQue ;(B1QueCh0 ~ B1QueCh31) and #0ffh ;ACC and 0ffh(保留低8位元) add #uTab ;(ACC)+#uTabACC tblr *,ar5 ;next *ar5:#CoefBase3c lar ar7,#3 ;4 Freq of 1st channel

Indirect: [label] tblr {ind} [,next ARP] tblr *,ar5 tblr : Table Read Syntax Direct: [label] tblr dma Indirect: [label] tblr {ind} [,next ARP] Execution (PC)+1 PC (PFC)  MCS (ACC(15-0)) PFC

承上tblr 所述: Then ( pma,addressed by PFC ) dma If ( repeat counter )/=0: Then ( pma,addressed by PFC ) dma Modify AR(ARP) and ARP as specified, ( PFC )+1 PFC (repeat counter )-1  repeat counter. Else ( pma,addressed by PFC )  dma, Modify AR(ARP) and ARP as specified. ( MCS ) PFC

Example

RecvInt4 RecvInt4 (2)計算X(n)+(-1)*Y(n-2) (3)計算cos(coef)*Y(n-1) ;Y(n)=X(n)+2*cos(coef)*Y(n-1)+(-1)*Y(n-2) ; (ar4) (1)計算Column係數 ;(4)計算X(n)-Y(n-2)+cos(coef)*Y(n-1) ;(5)再計算X(n)+2*cos(coef)*Y(n-1)+(-1)*Y(n-2) ;4 frequency IIR ;ar4PQue(B1QueCh0 ~ B1QueCh31;X(n)) ;ar5CoefBase3c,2c,1c(cos(coef)) ;ar6F32Ch0(Y(n-2)),F31Ch0(Y(n-1))

lt *-,ar4 ;ar5(CoefBase3c,2c,1c)TREG0,ar5=ar5-1 ;(CoefBase2c,1c,4r),next *PQue ---- (1) lacc *,12,ar6 ;ar4*2^12ACC,next *ar6 sub *-,16 ;(ACC)-[(F32Ch0~F11Ch31)*2^16]ACC ;ar6F31Ch0 ---------------------------- (2) mpy * ;(TREG0)*(ar6)PREG --------------- (3) ltd * ;(ar6)TREG0,(ar6)ar6+1-----------(4) ;(ACC)+PREGACC apac ;(ACC)+PREGACC

RecvInt5: ;Get high byte data sach *-,0,ar7 ;(ACC)(ar6+1),ar6-1, ;next *ar7(3) bcnd RecvInt5,ov ;if(Overflow Flag)=1, ;跳至RecvInt5執行 banz RecvInt4,*-,ar5 ;if ar7/=0,跳至RecvInt4執行 ov = 1 RecvInt5: ;Get high byte data

ltd * Previous Product,and Move Data Syntax Direct: [label] ltd dma ltd : Load TREG0,Accumulate Previous Product,and Move Data Syntax Direct: [label] ltd dma Indirect: [label] {ind}[,next ARP]

承上ltd所述: Execution (PC) +1 PC (dma) TREG0 (dma)  dma+1 (ACC) + (shifted P register)  ACC Affected by OVM ,PM,and TRM;affects C and OV.

RecvInt5 RecvInt5 adrk #4 ;ar5+4 pointer proces lar ar7,#3 lacl TempInt ;Get high byte data ;(TempInt)ACC(15-0) bsar 8 ;(ACC)/2^8ACC ----取出高8Bits ;ACCL(00000000 Ch1,3,5,..31) mar *,ar4 ;next *ar4(B1QueCh0) adrk #205 ;ar4+#205ar4 add #uTab ;(ACC)+#uTabACC tblr *,ar5 ;rear table,(ACC(15-0))(ar4)

以陣列形式表示Channel的資料結構 以陣列形式可將“Channel”與“點數”表示為 [Channel][點數] [0] [0] [0~31][0~204] : [0][204] 即 [0][0] [1] [0] : : : [1][204] [31][204] : [31] [0] : [31][204]

RecvInt6 RecvInt6 lt *-,ar4 ;4 frequency IIR of 2nd channel lacc *,12,ar6 sub *-,16 mpy * ltd * apac sach *-,0,ar7 bcnd RecvInt7,ov banz RecvInt6,*-,ar5

RecvInt7 ---告知已經Overflow adrk #4 ;pointer process,ar5+4 ;adrk #3 ;pointer process mar *,ar4 ;next *ar4,PQue ;(B1QueCh0 ~ B1QueCh31) adrk #205 ;ar4+#205ar4 lacc #0ffffh ;output level 0 to phone samm DXR ;(ACC)  DXR rete ;Enable Interrupts and From Interrupt

補充資料 補充: sammStore Accumulator in Memory-Mapped Register lmmr Load Memory-Mapped Register ; Ex: lmmr dma,#addr DXR Data transmit register DRR Data receive register XSR Transmit shift register (不能存取,但可 允許雙緩衝功能) RSR Receive shift register (不能存取,但可 IMR Interrupt mask register(16Bits)

The flow chart of INT2

The flow chart of the Check Peak level and Twist

Main Program ;------------------------------ Initialization ----------------------------------- Main: setc intm ;Set Interrupt Mode Bit in ST0 setc ovm ;Set Overflow Mode Bit in ST0 ldp #0 ;Load data memory pointer=0 opl #003ch,PMST ;ndx=1, ram=ovly=1 splk #00c8h,SPC ;soft=free=0, rrst=xrst=1, txm=0 ;mcm=0,fsm=1, fo=0 splk #00c8h,TSPC ;same SPC

Initialization spm 0 ;No shift of multiplier output (PM=00 in ST1) setc sxm ;sxm=1,produces sign extension on data as it is ;passed into the accumulator through the scaling shifter. clrc cnf ;B1 = data memory lmmr INDX,#Two ;indx=2 zap ;0-->ACC,0-->PREG sacl CWSR ;CWSR=PDWSR=IOWSR=0 sacl PDWSR sacl IOWSR splk #06h,IMR ;Series Recv Int on & Int2 & Int3

Block Move ;----------------------------------- block move---------------------------------- mar *,ar1 ;table move,*ar1 lar ar1,#CoefBase1r;CoefBase1rar1 rpt #Len-1 ;rpt #43 blpd #Table,*+ ;#Table=#0800h,#Table(ar1) ;------------------------------------------------------------------------------------- Table ar1 CoefBase1r Base1r CoefBase2r : : : 44 Harm1r : : : Len PB1QueCh0

lar ar1,#F11Ch31;clear filter result buffer6*32=192 rpt #191 sacl *+ clrc intm ldp #CoefBase1r ;check if need to process MainChk0: lar ar0,PGropSave0 ;PGropSave0(0)-->ar0 lar ar1,PGropSave1 ;PGropSave1(PProcFlg0)-->ar1 lar ar2,PGropSave2 ;PGropSave2(3)-->ar2

MainChk1 lacc * ;ar1(PProcFlg0)ACC bcnd MainProc0,neq ;PProcFlg(n)=? –1(Block(n)資料已經 ;填滿) mar *+,ar0 ; mar *+,ar2 ; banz MainChk1,*-,ar1; lar ar0,#0 ; lar ar1,#PProcFlg0 ; lar ar2,#3 ; b MainChk1 ;

MainProc(n) MainProc0: zap ;0ACC,0PREG sacl * ;0 ar1(PProcFlg(n)) sar ar0,PGropSave0 sar ar1,PGropSave1 sar ar2,PGropSave2 lacc #31 ;set PChSave=#31(32ch) sacl PChSave

MainProc1 MainProc1 lt PGropSave0 ;Group start then,PGropSave0TREG0 mpy #192 ;1.PFilC31b,PFilC31b pac adds PB1F31Ch31 ;PB1F31Ch31 sacl PFilC31b add One sacl PFilC32b

MainProc1(續) lt PGropSave0 ;2.PB1QueCh31 mpy #205*32 pac bd MainProc2 adds PB1QueCh31 ;PB1QueCh31 sacl PQueBuf

MainProc3 MainProc3: sar ar1,PChSave ;channel change then lacc PQueBuf,0 ;1.PQueBuf-205,channel-1 sub #205 sacl PQueBuf lacc PFilC31b ;2.PFilC31b+6&PFilC32b+6 add #6 sacl PFilC31b add One sacl PFilC32b MainProc2: lmmr INDX,#Two ;indx=2

; Caculate Energy at Col 1,2,3,4 and ; Find Max Energy of Col 1,2,3,4 ;ENERGY = [(Y(n-2)-Y(n-1))/2]^2 - Y(n-1)*Y(n-2)*(coef-1) EnergyCol: lar ar0,Two ;2ar0 lar ar1,PFilC32b ;(PFilC32b)ar1 lar ar2,#CoefBase3c ;(CoefBase3c)ar2 EnergyCol0: ;next * ar2 call EnergySr,*,ar2 ;ar2-1,[(ACC)*2^1]ar2 sach *-,1,ar0 ;next * ar0 banz EnergyCol0,*-,ar1 ;if ar0/=0,跳至EnergyCo10 ;執行,ar0-1,next * ar1

Find Column 1,2,3 Energy Max

Check Column 1,2,3,4 level and Relative peak ChkLev: lacc ColMaxDat ;ColMaxDat must >2^4,(acc) = (ColMaxDat) sub One,4 bcnd NotCode,lt ;if (ACC<0),執行NotCode ;--------------------------Check col1,2,3 Relative ratio-------------------------- ChkRelCol: ; mar *,ar1 : lar ar0,Two ;ar0=2 ar2One lar ar1,PFilC31b ;ar1=PFilC31b : lar ar2,One ;ar2=1 ar0Two lt ColMaxDat ;P=ColMaxDat*683 mpy #683 ar1PFilC31b PFilC32b 2 1

ChkRelCol0 lacc *0-,12,ar0 ;(ar1) - ColMaxDat*683 & ar1-2 spac bcnd ChkRelCol1,lt mar *,ar2 ;ar2 - 1 mar *-,ar0 ChkRelCol1 banz ChkRelCol0,*-,ar1 ;ar0 =?0 mar *,ar2 banz NotCode,*,ar1 ;ar2=?0

Clear Row & Harmonic Filter result ClearFil: lar ar1,#FilR11b zap rpt #7 sacl *+ lar ar1,#FilR01h rpt #3

Process DFT of ROW 1,2,3,4 ;********************************************************* ; Process DFT of Row 1,2,3,4 DFTRow: lar ar0,BaseLen ;ar0 = 204 lar ar1,#FilR12b lar ar2,PQueBuf lar ar3,#CoefBase1r lacc Four sacl FreqCout4 call DFTCall,*,ar3

Caculate Energy at ROW 1,2,3,4 ;********************************************************* ; Caculate Energy at Row 1,2,3,4 and ; Find Max Energy of Row 1,2,3,4 ;ENERGY = [(Y(n-2)-Y(n-1))/2]^2 - Y(n-1)*Y(n-2)*(coef-1) EnergyRow: lar ar0,Three lar ar1,#FilR42b lar ar2,#CoefBase4r EnergyRow0: call EnergySr,*,ar2 ;21 sach *-,1,ar0 ;23..ar1 - 1 (Y(n-2) banz EnergyRow0,*-,ar1 ;24..ar0(FreqCount)=?0 ar0-1

;---------------------- Find Row 1,2,3,4 Energy Max -------------------------- ;RowMaxDat = row peak data RowMaxNo= row peak number FindRowMax: ; mar *,ar1 lacc Three ;RowMaxNo=3 sacl RowMaxNo FindRow lar ar2,Two ;ar2=2 lar ar1,#FilR41b ;RowMaxDat=(#FilR41b)&ar1=#FilR31b lacc *0- sacl RowMaxDat

FindRow0 lacc RowMaxDat sub * bcnd FindRow1,geq ;RowMax - (ar1) sar ar2,RowMaxNo lacc * sacl RowMaxDat FindRow1 mar *0-,ar2 banz FindRow0,*-,ar1

;Check Peak level and Twist TwistLevel: lacc ColMaxDat ;(ColMaxDat)-(RowMaxDat)ACC sub RowMaxDat bcnd TwistLevel0,geq ;if (ACC >=0)執行TwistLevel0 TwistRev lac ColMaxDat ;row > col sub One,4 bcnd NotCode,lt lac RowMaxDat ;row_max - col_max*12 sub ColMaxDat,3 ;8dB = 12 sub ColMaxDat,2

bcnd NotCode,geq ;row_max > =col_max*12執行NotCode b DFTHarmRow TwistLevel0: lac RowMaxDat ;col > row sub One,4 bcnd NotCode,lt lac ColMaxDat ;col_max - row_max*3 sub RowMaxDat ;4dB = 3 sub RowMaxDat,1 bcnd NotCode,geq ;col_max >= row_max*3執行NotCode

;------- Process 2nd Harmonic DFT of Max Row Energy------- DFTHarmRow: mar *,ar3 lmmr INDX,#RowMaxNo ;INDX=3 lar ar0,HarmLen ;ar0=200 lar ar1,#FilR02h lar ar2,PQueBuf lar ar3,#CoefHarm1r mar *0+,ar3 lt *,ar2 ;1..T = Cos(*)

DFTHarmRow0之資料結構

DFTHarmRow0 lacc *+,12,ar1 ;3..X(n) sub *-,16 ;X(n)-Y(n-2) --> Acc mpy * ;Cos(*) * Y(n-1) --> P ltd *,ar3 ;X(n)+ Cos(*) * Y(n-1)-Y(n-2) ;Y(n-1)-->Y(n-2) lta *,ar1 ;X(n)+2Cos(*) * Y(n-1)-Y(n-2) apac apac ;X(n)+2*2Cos(*)*Y(n-1)-Y(n-2) sach *+,0,ar0 ;2..--> Y(n-1) Q30 bcnd HarmRowLev,ov ;check overflow banz DFTHarmRow0,*-,ar2 ;4..ar0(len)=?0

;--------------- Check Row Harmonic Energy ------------- HarmRowLev: ; mar *,ar2 lar ar2,#CoefHarm1r;ar2 = harmonic coefficent Pointer mar *0+,ar2 ;= #coeff + row_max*2 lar ar1,#FilR02h ;ar1 = harmonic data pointer ;= #dat + row_mxp*2 call EnergySr,*,ar2 lt RowMaxDat ;harmonic energy row_max/4 mpy #4096 spac bcnd NotCode,geq

;********************************************************* ; Process 2nd Harmonic DFT of Max Col Energy and ; Check Col Harmonic Energy ;*********************************************************DFTHarmCol: mar *,ar3 lmmr INDX,#ColMaxNo ;INDX=1 lar ar0,HarmLen ;ar0=200 lar ar1,#FilC02h lar ar2,PQueBuf lar ar3,#CoefHarm1c mar *0+,ar3 lt *,ar2 ;1..T = Cos(*)

DFTHarmCol0 lacc *+,12,ar1 ;3..X(n) sub *-,16 ;X(n)-Y(n-2)--> Acc mpy * ;Cos(*) * Y(n-1)--> P ltd *,ar3 ;X(n)+ Cos(*) * Y(n-1)-Y(n-2) ;Y(n-1)-->Y(n-2) lta *,ar1 ;X(n)+2Cos(*) * Y(n-1)-Y(n-2) apac apac ;X(n)+2*2Cos(*)*Y(n-1)-Y(n-2) sach *+,0,ar0 ;2..--> Y(n-1) Q30 bcnd HarmColLev,ov ;check overflow banz DFTHarmCol0,*-,ar2 ;4..ar0(len)=?0

DFTHarmCol0之資料結構

;----------------- Check Col Harmonic Energy ------------ HarmColLev: mar *,ar2 lar ar2,#CoefHarm1c ;ar2 = harmonic coefficent pointer mar *0+,ar2 ;= #Coef + ColMax*2 lar ar1,#FilC02h ;ar1=harmonic data pointer = #dat + ;ColMax*2 call EnergySr,*,ar2 lt ColMaxDat ;harmonic energy ColMax/4 mpy #4096 spac bcnd NotCode,geq

;********************************************************* ; Check for valid number ; Compare number with last number and 2nd to last number ;********************************************************* ;--------------------------------- load recognized number ---------------------- mar *,ar1 lt PChSave ;ch*3 + #Last1Ch0 mpy Three ;(PChSave)*3PREG lacc #Last0Ch0 ;ACC= #Last0Ch0 apac ;(ACC)+(PREG)ACC sacl TempMain,0 lar ar1,TempMain

mar *+,ar1 ;Last0Ch0+1 = Last1Ch0 dmov *- ;last1 --> last2 dmov * ;last0 --> last1

;----------------------- Check for new number ------------ ChkNewCode: lacc RowMaxNo,2 ;row_mxp*2^2 + col_mxp + Ch*2^8 ;--> last0 add ColMaxNo add PChSave,8 sacl *+ ;--> last0 mar *+,ar1 sub *- ;last0 =? last2 bcnd NotCode1,eq ;ACC(last0-last2)=0,執行NotCode1

lac *- ;last0 =? last1 sub *,0,ar1 bcnd ChkNewCode0,neq ;last0/=last1,執行ChkNewCode0 out *,3 ;Output Last0 Digital data ChkNewCode0 lar ar1,PChSave banz MainProc3,*-,ar1 ;PChSave=?0 & PChSave-1 b MainChk0 ;Load ar0,ar1,ar2

Not New Code -當(1)row_max-col_max >=8dB (2)col_max-row_max>=4dB 時執行 NotCode: lt PChSave ;ch*3 + #Last0Ch0 mpy Three lacc #Last0Ch0 apac ;ch*3 + #Last0Ch0ACC sacl TempMain,0 ;ACCTempMain NotCode1 lar ar1,TempMain mar *,ar1 lacc #0ffh bd ChkNewCode0 dmov * ;last0 --> last1 sacl *

;******************************************************** ; DFT Subroutine DFTCall: lt *,ar2 ;1..T = Cos(*) ,next *ar2 ;*ar3(CoefBase1r,2r,3r,4r) DFTCall0 lacc *+,12,ar1 ;3..X(n) sub *-,16 ;X(n)-Y(n-2)--> Acc mpy * ;Cos(*) * Y(n-1) --> P ltd *,ar3 ;X(n)+ Cos(*) * Y(n-1)-Y(n-2) ;Y(n-1)-->Y(n-2) lta *,ar1 ;X(n)+2Cos(*) * Y(n-1)-Y(n-2) apac apac ;X(n)+2*2Cos(*)*Y(n-1)-Y(n-2) sach *+,0,ar0 ;2..--> Y(n-1) Q30 bcnd DFTCall1,ov ;check overflow banz DFTCall0,*-,ar2 ;4..ar0(len)=?0

DFT Subroutine之資料結構

DFTCall1 lar ar0,BaseLen ;ar0=204 lar ar2,PQueBuf mar *,ar1 mar *0+,ar3 mar *+,ar3 lacc FreqCout4 ;FreqCout4-1 sub One sacl FreqCout4 bcnd DFTCall,neq ;ACC(FreqCout4-1)/=0,跳至DFTCall執行 ret

Energy Subroutine ar2=(coeff-1),負責指到Coefficent ar1Y(n-2),ar1-1Y(n-1) CoefBase1r ~CoefHarm4c ar2=(coeff-1),負責指到Coefficent ar1Y(n-2),ar1-1Y(n-1) 運算式:[(Y(n-2)-Y(n-1))/2]^2-Y(n-1)*Y(n-2)*(coef-1) 執行步驟:(1).(coef-1)/2 (2).Y(n-2)*(coef-1)/2 (3).Y(n-1)*Y(n-2)*(coef-1)/2 (4).ABS[Y(n-2)-Y(n-1)]/2 (5).{[Y(n-2)-Y(n-1)]/2} ^2 (6).{[Y(n-2)-Y(n-1)]/2}^2-Y(n-1)*Y(n-2)*(coef-1)

;------------------- ENERGY Subroutine-------------------- EnergySr: lac NegMax,15 ;(coef-1)/2 add *-,15,ar1 ;ar2=&coeff-1 sach TempMain ;[(Coef-1)/2]TempMain lt *- ;Y(n-2)*(coef-1)/2,Y(n-2)TREG0 mpy TempMain ;(TREG0)*(TempMain)PREG pac ;[Y(n-2)*(coef-1)/2]ACC sach TempMain,1 lt *+ ;Y(n-1)*Y(n-2)*(coef-1)/2,Y(n-1)Y(n-2) mpy TempMain

pac sach TempMain,1 lac *-,15 ;ABS[Y(n-2)-Y(n-1)]/2,Y(n-1)Y(n-2) sub *,15 ;*Y(n-1) abs sach * lt * ;[Y(n-2)-Y(n-1)]/2 ^2 mpy * pac ;[(Y(n-2)-Y(n-1))/2]^2-Y(n-1)*Y(n-2)*(coef-1) sub TempMain,15 ret

Energy Subroutine ;caculate Energy at column 1,2,3: ;ar0=2,ar1PFilC32b,ar2CoefBase3c

Energy Subroutine(續) ;caculate Energy at Row 1,2,3,4: ;ar0=3,ar1FilR42b,ar2CoefBase4r

Energy Subroutine(續) ;check column Harmonic Energy ;ar0HarmLen(200),ar1FilC02h,ar2CoefHarm1c

Energy Subroutine(續) ;check Row Harmonic Energy: ;ar0HarmLen(200),ar1FilR02h,ar2CoefHarm1r

謝謝各位指導!! 學生:劉念宗 製作