#include <math.h>
#include "6722.h"
#include "DSPF_sp_cfftr2_dit.h"
#include "DSPF_sp_icfftr2_dif.h"
#include "gen_w_r2.h"
#include "bit_rev.h"
#include "divide.h"
main()
{
int i;
int FH,F1;
initPLLc();
initIntc();
initRTI();
InitMyEmif();
PDIR1 = 0x1<<2 | 0x1<<3;
PFUNC1=0x0c;
AD=1;//ADMAX1322选用1通道
//双口RAM开始地址发送DDS数据,频率1000Hz单频信号
HBIT=0x00;//控制低地址
initDDS();
gen_w_r2(w, N);
bit_rev(w, N >> 1);
while (1)
{
if(num>=0x1000)
{
PDOUT1^=0x0c;
num=0;
msamp1(cainum);
msamp2();
DSPF_sp_cfftr2_dit(x, w, N);
bit_rev(x, 8192);
for(i = 0; i <4096; i++)//求4096点的功率谱
{
PWADDR[i] = sqrt(x[2*i]*x[2*i] +x[2*i+1]*x[2 *i +1]);
}
find(&FH,&F1);
}
}
}
/*********************************************************************
** Function name: initDDS
**
** Descriptions: DDS AD9850初始化
F1表示调频值,FL为上变频
**********************************************************************/
void initDDS(void)
{
int F1=290;
int FL=1711;
int FH=1689;
FL=FL*178.95967+0.5;
FH=FH*178.95967+0.5;
*(short int *)(shuangkou+2)=9;//数据长度
*(short int *)(shuangkou+4)=F1;//DDS FS
*(short int *)(shuangkou+6)=FL&0xffff;//FREQ0L
*(short int *)(shuangkou+8)=(FL>>16)&0xffff;//FREQ0H
*(short int *)(shuangkou+10)=FH&0xffff;//FREQ1L
*(short int *)(shuangkou+12)=(FH>>16)&0xffff;//FREQ1H
*(short int *)(shuangkou+14)=0;
*(short int *)(shuangkou+16)=0;
*(short int *)(shuangkou+18)=0;
*(short int *)(shuangkou+20)=0;
*(short int *)shuangkou=0x5555;//标志位
}
/*********************************************************************
** Function name: interrupt comp0Isr
**
** Descriptions: 中断服务子程序,每次中断后要清除中断
**********************************************************************/
void interrupt comp0Isr()
{
int j;
j=AD;
j+=0x2000;
j=j&0x3fff;
ADSTART=j;
AD_sample(cainum,j);
cainum++;
cainum%=8192;
num+=1;
/* Clear the interrupt */
*(int *)0x42000088 = 1;
}
/*********************************************************************
** Function name: initIntc
**
** Descriptions: 中断设置寄存器
**********************************************************************/
cregister unsigned int ISTP,CSR,IER;
void initIntc( void )
{
CSR &= ~1; //控制状态寄存器,可屏蔽中断禁止
ISTP=0x10000000; //中断服务表指针,指向中断服务表起始地址
IER=0x12; //中断使能寄存器 ,定时器使能
CSR |=1; // 可屏蔽中断使能
}
/*********************************************************************
** Function name: initPLLc
**
** Descriptions: 锁相环配置寄存器
**********************************************************************/
#define PLLPID *(int *)0x41000000 //锁相环控制器外围验证寄存器
#define PLLCSR *(int *)0x41000100 //锁相环控制/状态寄存器
#define PLLM *(int *)0x41000110 //锁相环倍频控制寄存器
#define PLLDIV0 *(int *)0x41000114 //锁相环控制器分频器寄存器0
#define PLLDIV1 *(int *)0x41000118 //锁相环控制器分频器寄存器1
#define PLLDIV2 *(int *)0x4100011C //锁相环控制器分频器寄存器2
#define PLLDIV3 *(int *)0x41000120 //锁相环控制器分频器寄存器3
#define PLLCMD *(int *)0x41000138 //锁相环控制器命令寄存器
#define PLLSTAT *(int *)0x4100013C //锁相环控制器状态寄存器0
#define ALNCTL *(int *)0x41000140 //锁相环控制器时钟对齐控制寄存器
#define CKEN *(int *)0x41000148 //时钟使能控制寄存器
#define CKSTAT *(int *)0x4100014C //时钟状态寄存器
#define SYSTAT *(int *)0x41000150 //系统时钟状态寄存器
#define CFGBRIDGE *(int *)0x40000024// /// 锁相环改变后的复位控制
void initPLLc( void )
{
//当PLLEN不等于0且PLLRST不等于1时,需要设置,当设备正从复位状态脱离时,默认情况下:PLLEN=0,PLLRST=1
int i;
PLLCSR = 0; //PLLEN=0 时为旁路模式,D0和锁相环被旁路掉,同时输入参考时钟被直接输入分频器D1,D2,D3。在67系列DSP中锁相环被默认设置成旁路模式
for(i=0;i<6000;i++); //delay
PLLCSR |= 8; // PLLRST =1 PLLC reset 锁相环复位
PLLDIV0 = 0x8000 | 1; //D0en =1(使能) PLLDIV0 = 2(1表示除以2) CLKIN = 20Mhz PLLIN =10Mhz
PLLM = 20; // 10Mhz x 20 = 200MHz 、、、错误????
for(i=0;i<6000;i++); //delay 等待锁相环正确复位
while( ( ( PLLSTAT ) & 1 ) == 1 );
PLLDIV1 = 0x8000 | 0; //D1en =2 PLLDIV1 = 3 CLKIN = 200Mhz PLLout =66Mhz
PLLDIV2 = 0x8000 | 1; //D1en =1 PLLDIV2 = 2 CLKIN = 200Mhz PLLout =100Mhz
PLLDIV3 = 0x8000 | 2; //D3en =2 PLLDIV3 = 3 CLKIN = 200Mhz PLLout =66Mhz,控制EMIF,不能超过100M
ALNCTL = 7;
PLLCMD = 1;
while( ( ( PLLSTAT ) & 1 ) == 1 );
for(i=0;i<6000;i++); //delay
/* Set PLLRST = 0 */
/* Set PLLRST to ASSERTED */
PLLCSR &= ~8; //锁相环退出复位状态
for(i=0;i<6000;i++); //delay //等待锁相环锁定
PLLCSR |= 1; //使能锁相环模式
}
/*********************************************************************
** Function name: initRTI
**
** Descriptions: 定时器配置寄存器,定时器时钟源为分频器2
**********************************************************************/
#define CFGRTI *(int *)0x40000014 ////选择寄存器捕捉源
#define RTIGCTRL *(int *)0x42000000 //全局控制寄存器,用于启停定时器
#define RTICAPCTRL *(int *)0x42000008 //捕捉控制寄存器,控制计数器的捕捉源
#define RTICOMPCTRL *(int *)0x4200000C //比较控制寄存器,控制比较寄存器源
#define RTIFRC0 *(int *)0x42000010 //自由运行计数器0,自由运行计数器0的当前值
#define RTIUC0 *(int *)0x42000014 //递增计数器0,预定标计数器0的当前值
#define RTICPUC0 *(int *)0x42000018 //比较递增计数器0,与预定标计数器0的比较值
#define RTICAFRC0 *(int *)0x42000020 //自由运行计数器0捕捉寄存器,自由运行计数器0捕捉外部事件的当前值
#define RTICAUC0 *(int *)0x42000024 //递增计数器0捕捉寄存器,预定标计数器0捕捉外部事件的当前值
#define RTIFRC1 *(int *)0x42000030 //自由运行计数器1,自由运行计数器1的当前值
#define RTIUC1 *(int *)0x42000034 //递增计数器1,预定标计数器1的当前值
#define RTICPUC1 *(int *)0x42000038 //比较递增计数器1,与预定标计数器1的比较值
#define RTICAFRC1 *(int *)0x42000040 //自由运行计数器1捕捉寄存器,自由运行计数器1捕捉外部事件的当前值
#define RTICAUC1 *(int *)0x42000044 //递增计数器1捕捉寄存器,预定标计数器1捕捉外部事件的当前值
#define RTICOMP0 *(int *)0x42000050 //比较寄存器0
#define RTIUDCP0 *(int *)0x42000054 //更新比较寄存器0
#define RTICOMP1 *(int *)0x42000058 //比较寄存器1
#define RTIUDCP1 *(int *)0x4200005C //更新比较寄存器1
#define RTICOMP2 *(int *)0x42000060 //比较寄存器2
#define RTIUDCP2 *(int *)0x42000064 //更新比较寄存器2
#define RTICOMP3 *(int *)0x42000068 //比较寄存器3
#define RTIUDCP3 *(int *)0x4200006C //更新比较器3,比较匹配时,比较值载入寄存器3
#define RTISETINT *(int *)0x42000080 //使能中断
#define RTICLEARINT *(int *)0x42000084 //清楚中断
#define RTIINTFLAG *(int *)0x42000088 //中断标志
#define RTIDWDCTRL *(int *)0x42000090 //数字看门狗控制寄存器,使能看门狗
#define RTIDWDPRLD *(int *)0x42000094 //数字看门狗预置寄存器,设置看门狗的周期
#define RTIWDSTATUS *(int *)0x42000098 //数字看门狗状态寄存器
#define RTIWDKEY *(int *)0x4200009C //数字看门狗钥匙
#define RTIDWDCNTR *(int *)0x420000A0 //数字看门狗递减计数器
void initRTI( void )
{
RTIGCTRL =0; //COUNTER STOP 停止定时器
RTICAPCTRL = 3;
RTIFRC0 = 0;
RTICPUC0 = 0x2FAE; //比较递增计数器预设值,FRC0=RTCLK/(CPUC0+1)
RTICOMP0 = 3;//比较寄存器0预设值
RTIUDCP0 = 1; //更新比较寄存器0预设值
RTIINTFLAG = 0xffffffff; //中断标志
RTICLEARINT =1;
RTISETINT = 1;
RTIGCTRL = 1;//启动ㄆ?
}
FFT.rar_DDS DSP_FFT 浮点_FSK dsp_dsp fsk_fsk
版权申诉
74 浏览量
2022-09-19
18:53:39
上传
评论
收藏 108KB RAR 举报
![avatar](https://profile-avatar.csdnimg.cn/3542a6830a364bf6a0adb34bfd72ce9d_weixin_42662605.jpg!1)
APei
- 粉丝: 65
- 资源: 1万+
最新资源
- 一个基于Python编程语言和numpy及matplotlib库的简单正弦波信号发生器示例
- jdk-17-linux-x64-bin.deb
- jdk-17-linux-aarch64-bin.rpm
- 折线图、散点图、柱状图和饼图,每个示例都显示了如何显示中文
- asp.net高校网上教材征订系统的设计与实现(源码)
- asp.net动态口令认证的网上选课系统的设计与实现(源码)
- NetAssist网络调试助手
- ASP.NET公文管理系统的设计与实现(源码)
- 操作系统原理与设计Chapter 2: OS Structure
- torch-2.3.1-cp312-cp312-manylinux2014-aarch64.whl
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback-tip](https://img-home.csdnimg.cn/images/20220527035111.png)
评论0