本帖最后由 qq807051639 于 2014-5-29 13:51 编辑
程序如下
QPSK调制即发射机的DSP实现
子程序说明
data_input 子程序用来从外部读入2b数据。
base_wave子程序用来进行基带低通根升余弦特性滤波,形成基带滤波。
freq_modem子程序用来将基带波形调制到48KHZ的载波上。
输入输出:
程序从外部变量DATA2读入2b数据
经过处理后,数据输出至D/A缓冲区SBW_DAB,形成16b数据
符号设定
SW_FILR.set 500H
SW_FILI.set 600H
SW_FILL.set 80H
SW_48k.set 700H
SW_NULL.set 800H
SW_2PP.set SW_NULL+51
SW_2PN .set SW_NULL+102
SW_4PP .set SW_NULL+153
SW_4PN .set SW_NULL+204
SW_DAB .set 6000H
SW_DABL.set 200H
SW_FILIN和SW_FILOUT分别作为滤波缓冲区的入口和出口
SW_DAIN和SW_DAOUT分别作为D/A缓冲区的入口和出口
主要部分程序
psk_modem
CALL data_input
CALL base_wave
CALL freq_modem
RET
ini_mod
data_input
LD DATA2,A
AND #11B,A ;读入2b数据
SFTL A,2 ;乘4
ADD #wave_table,A
READA DATA0;R(t)读入点
ADD #1,A
READA DATA1;I(t)读入点
RET
base_wave
LD SW_FILIN,A;R(t)滤波缓冲区的入口放到A中
STLM A,AR1
ADD #100H,A;I(t)滤波缓冲区的入口比R(t)大100H
STLM A,AR2
LD DATA0,A
STLM A,AR3
LD DATA1,A
STLM A,AR4
STM #50,BRC;块重复执行51次
RPTBD change_in_pointer-1;快下界到change_in_pointer之前
STM #80H,BK ;设循环寻址的大小为80H
LD *AR3+,A
ADD *AR1,A
STL A,*AR1+%
LD *AR4+,A
ADD *AR2,A
STL A,*AR2+%
change_in_pointer
LD SW_FILIN,A;更改滤波缓冲区的入口
SUB #SW_FILR,A
ADD #6,A
AND #7FH,A
ADD #SW_FILR,A
STL A,SW_FILIN
RET
freq_modem
LD SW_DAOUT,A;将D/A缓冲区的出口放到A中
SUB SW_DAIN,A;D/A缓冲区的出口值减入口地址值
NOP
NOP
XC 2,ALEQ
ADD #SW_DABL,A
NOP
SUB #90H,A
BC sw_mod00,ALT;检查D/A缓冲区是否满
RSBX SXM
LD SW_FILIN,A
SUB SW_FILOUT,A
NOP
NOP
XC 2,ALT
ADD #80H,A
NOP
SUB #10H,A
SSBX SXM
BC sw_mod02,AGEQ;检查是否可以滤波
LD BIT_标志寄存器,A
AND #11B,A
BC sw_mod00,ANEQ;检查D/A缓冲区是否满
sw_mod02
LD SW_FILOUT,A
STLM A,AR2
ADD #100H,A
STLM A,AR3
LD SW_DAIN,A
ADD #SW_DAB,A;计算D/A缓冲区入口地址
STLM A,AR1
ST #3000H,DATA1
STM #SW_48K,AR4;余弦表的首地址放入AR4
STM #SW_48K+2,AR5;正弦表的首地址放入AR5
STM #7,BRC
RPTBD sw_mod01-1
STM #80H,BK
MPY *AR2,*AR4+,A
MACR *AR3,*AR5+,A;两路信号载波调制后相加
STH A,DATA0
LD DATA1,T
MPY DATA0,A
STH A,*AR1+;保存D/A数据
LD #0,A;清除数据
STL A,*AR2+%
STL A,*AR3+%
sw_mod01
MVKD AR2,SW_FILOUT
LD SW_DAIN,A
ADD #8,A
AND #SW_DABL-1,A
STL A,SW_DAIN
sw_mod00
RET
ini_mod
SSBX FRCT
STM #SW_NULL,AR1
RPTZ A,#50
STL A,*AR1+;清空SW_NULL缓冲区
STM #SW_2PP,AR1
RPT #50
MVPD #scr_wave,*AR1+;从程序空间向数据空间读书据
NOP
STM #50,BRC;产生2PN波形表
STM #SW_2PP,AR1;
STM #SW_2PN,AR2
RPTB scr_movd00-1
LD *AR1+,A
NEG A
STL A,*AR2+
scr_movd00
ST #5A82H,DATA0;将值0.707放入DATA0中
LD DATA0,T
STM #50,BRC
STM #SW_2PP,AR1;
STM #SW_4PP,AR2;产生4pp波形表
STM #SW_4PN,AR3;产生4PN波形表
RPTB scr_movd01-1
MPY *AR1+,A
STH A,*AR2+
NEG A
STH A,*AR3+
scr_movd01
STM #SW_48K,AR1;正弦表移入SW_48k中
RPT #0FH
MVKD #sin_tab,*AR1+
RET
wave_table
.word SW_2PP,SW_NULL;数据为00的情况
.word SW_4PP,SW_4PP
.word SW_NULL,SW_2PP;数据为01的情况
.word SW_4PN,SW_4PP
.word SW_2PN,SW_NULL;数据为10的情况
.word SW_4PN,SW_4PN
.word SW_NULL,SW_2PN;数据为11的情况
.word SW_4PP,SW_4PN
scr_wave;滚降系数为0.35的根升余弦表
.word 0fff6H,00003H,00013H,0001eH,00019H,0fffaH,0ffc1H,0ff89H,0ff85H
.word 0ffe8H,000c2H,001dcH,002a9H,0026aH,00087H,0fcf9H,0f89cH,0f53cH
.word 0f52aH,0fa7eH,00633H,01781H,02bb9H,03ed2H,04c7dH,05174H,04c7dH
.word 03ed2H,02bb9H,01781H,00633H,0fa7eH,0f52aH,0f53cH,0f89cH,Ofcf9H
.word 00087H,0026aH,002a9H,001dcH,000c2H,0ffe8H,0ff85H,0ff89H,0ffc1H
.word 0fffaH,00019H,0001eH,00013H,0fff6H
sin_tab;8点分正弦波表
.word 00000H,05a82H,07fffH,05a82H,00000H,0a57fH,08002H,0a57fH
.word 00000H,05a82H,07fffH,05a82H,00000H,0a57fH,08002H,0a57fH
.end
在CCS3.3 Graph窗口中看结果图 地址应该是多少 |