打印
[DSP编程]

dsp28335 initsysctrl()

[复制链接]
3234|8
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
七颗咖啡豆|  楼主 | 2015-11-18 17:16 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
沙发
zhangmangui| | 2015-11-18 22:03 | 只看该作者
找个好使的例子对比一下  吧   
下载controlSUITE里面有相关例子

使用特权

评论回复
板凳
七颗咖啡豆|  楼主 | 2015-11-20 10:03 | 只看该作者
#include "DSP2833x_Device.h"     // DSP2833x Headerfile Include File
#include "DSP2833x_Examples.h"   // DSP2833x Examples Include File
#include "math.h"
#include "IIR.h"
#include "stdio.h"

#define          LED1        GpioDataRegs.GPADAT.bit.GPIO0
#define          LED2        GpioDataRegs.GPADAT.bit.GPIO1
#define          LED3        GpioDataRegs.GPADAT.bit.GPIO2
#define          LED4        GpioDataRegs.GPADAT.bit.GPIO3
#define          LED5        GpioDataRegs.GPADAT.bit.GPIO4
#define          NN 512
#define   pi 3.14159
void configtestled(void);

void main(void)
{
        int i;
        int x[NN],y[NN];
// Step 1. Initialize System Control:
// PLL, WatchDog, enable Peripheral Clocks
// This example function is found in the DSP2833x_SysCtrl.c file.
   InitSysCtrl();

// Step 2. Initalize GPIO:
// This example function is found in the DSP2833x_Gpio.c file and
// illustrates how to set the GPIO to it's default state.
// InitGpio();  // Skipped for this example
   InitXintf16Gpio();        //zq

// Step 3. Clear all interrupts and initialize PIE vector table:
// Disable CPU interrupts
   DINT;

// Initialize the PIE control registers to their default state.
// The default state is all PIE interrupts disabled and flags
// are cleared.
// This function is found in the DSP2833x_PieCtrl.c file.
   InitPieCtrl();

// Disable CPU interrupts and clear all CPU interrupt flags:
   IER = 0x0000;
   IFR = 0x0000;

// Initialize the PIE vector table with pointers to the shell Interrupt
// Service Routines (ISR).
// This will populate the entire table, even if the interrupt
// is not used in this example.  This is useful for debug purposes.
// The shell ISR routines are found in DSP2833x_DefaultIsr.c.
// This function is found in DSP2833x_PieVect.c.
   InitPieVectTable();
   configtestled();

   //   LED1=1;
  // DELAY_US(10);
  //    LED2=1;
  // DELAY_US(10);
      LED1=0;
   DELAY_US(10);
      LED2=0;
   DELAY_US(10);
      LED3=0;
   DELAY_US(10);
      LED4=0;
   DELAY_US(10);  
      LED5=0;
   DELAY_US(10);  
   for(i=0;i<NN;i++)
           {
                   x[i]=32768*( cos(2*pi*50*i/1024)+cos(2*pi*300*i/1024) );
           }
while(1)
{
         for(i=0;i<NN;i++)//屏蔽掉这个循环,就正常。加上后就卡在InitSysCtrl();中
        {
                y[i]=IIR(x[i]);//
        }

      LED1=~LED1;
   DELAY_US(100000);
      LED2=~LED2;
   DELAY_US(100000);
      LED3=~LED3;
   DELAY_US(100000);
      LED4=~LED4;
   DELAY_US(100000);
      LED5=~LED5;
   DELAY_US(100000);
     }

}




void configtestled(void)
{
   EALLOW;
   GpioCtrlRegs.GPAMUX1.bit.GPIO0 = 0; // GPIO0复用为GPIO功能
   GpioCtrlRegs.GPADIR.bit.GPIO0 = 1;  // GPIO0设置为输出
   GpioCtrlRegs.GPAMUX1.bit.GPIO1 = 0; // GPIO1 = GPIO1
   GpioCtrlRegs.GPADIR.bit.GPIO1 = 1;
   GpioCtrlRegs.GPAMUX1.bit.GPIO2 = 0; // GPIO0复用为GPIO功能
   GpioCtrlRegs.GPADIR.bit.GPIO2 = 1;  // GPIO0设置为输出
   GpioCtrlRegs.GPAMUX1.bit.GPIO3 = 0; // GPIO1 = GPIO1
   GpioCtrlRegs.GPADIR.bit.GPIO3 = 1;
   GpioCtrlRegs.GPAMUX1.bit.GPIO4 = 0; // GPIO1 = GPIO1
   GpioCtrlRegs.GPADIR.bit.GPIO4 = 1;
   EDIS;
}
//===========================================================================
// No more.
//===========================================================================


使用特权

评论回复
地板
七颗咖啡豆|  楼主 | 2015-11-20 10:04 | 只看该作者
#include "IIR.h"
double        IIR_NUM[Nmbr_of_S][3]={{1,2,1},{1,2,1},{1,2,1},{1,1,0}};//Nmbr_of_S=4
double        IIR_DEM[Nmbr_of_S][3]=
                                {
                                        {1,   -1.314474906723,   0.7447131399677},
                                        {1,   -1.068673995798,   0.4184596094403},
                                        {1,   -0.946227509319,   0.2559354008692},
                                        {1,   -0.454527052386,                 0}
                                };
double  IIR_G[4]={ 0.1075595583111,0.0874464034107,0.07742697288753,0.272736473807};
int IIR(int x_ad)
{
        int i,y_da;

        double x[Nmbr_of_S+1];
        double w2[Nmbr_of_S],w1[Nmbr_of_S],w0[Nmbr_of_S],m2[Nmbr_of_S],m1[Nmbr_of_S],m0[Nmbr_of_S];


        x[0] = x_ad/32768.0;
        for(i=0;i<Nmbr_of_S;i++)
        {
                m0[i]=x[i];
                m1[i]=m0[i];
                m2[i]=m1[i];
                w2[i]=IIR_NUM[i][2]*m0[i]+IIR_NUM[i][1]*m1[i]+IIR_NUM[i][0]*m2[i]-IIR_DEM[i][1]*w1[i]-IIR_DEM[i][2]*w0[i];
                if(w2[0]>32767) w2[i]=32767;
                if(w2[0]<-32767) w2[i]=-32767;
                w0[i]=w1[i];
                w1[i]=w2[i];
                x[i+1]=w2[i]*IIR_G[i];
        }
       
        y_da=(int)(x[Nmbr_of_S]*32768.0);
        return y_da;

}

//===========================================================================
// No more.
//===========================================================================

使用特权

评论回复
5
七颗咖啡豆|  楼主 | 2015-11-20 10:05 | 只看该作者
CCS6.0

使用特权

评论回复
6
七颗咖啡豆|  楼主 | 2015-11-20 10:17 | 只看该作者
IIR算法我软仿OK了的,系数matlab生成的。

使用特权

评论回复
7
527664313| | 2018-4-21 09:47 | 只看该作者
朋友,你的dsp卡在InitSysCtrl()的问题解决了吗

使用特权

评论回复
8
gaominjie| | 2019-11-19 21:09 | 只看该作者
527664313 发表于 2018-4-21 09:47
朋友,你的dsp卡在InitSysCtrl()的问题解决了吗

我也卡在InitSysCtrl()了

使用特权

评论回复
9
zuoanhuafeng| | 2019-11-22 08:47 | 只看该作者
看看时钟配置的对不对?

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

51

主题

508

帖子

4

粉丝