七颗咖啡豆 发表于 2015-11-18 17:16

dsp28335 initsysctrl()

硬件仿真,一直再initsysctrl()这个函数中的三个函数循环,不能出去???
有遇到相同情况的么:'(

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,y;
// 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=32768*( cos(2*pi*50*i/1024)+cos(2*pi*300*i/1024) );
           }
while(1)
{
       for(i=0;i<NN;i++)//屏蔽掉这个循环,就正常。加上后就卡在InitSysCtrl();中
        {
                y=IIR(x);//
        }

      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={{1,2,1},{1,2,1},{1,2,1},{1,1,0}};//Nmbr_of_S=4
double        IIR_DEM=
                                {
                                        {1,   -1.314474906723,   0.7447131399677},
                                        {1,   -1.068673995798,   0.4184596094403},
                                        {1,   -0.946227509319,   0.2559354008692},
                                        {1,   -0.454527052386,               0}
                                };
doubleIIR_G={ 0.1075595583111,0.0874464034107,0.07742697288753,0.272736473807};
int IIR(int x_ad)
{
        int i,y_da;

        double x;
        double w2,w1,w0,m2,m1,m0;


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

}

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

七颗咖啡豆 发表于 2015-11-20 10:05

CCS6.0

七颗咖啡豆 发表于 2015-11-20 10:17

IIR算法我软仿OK了的,系数matlab生成的。

527664313 发表于 2018-4-21 09:47

朋友,你的dsp卡在InitSysCtrl()的问题解决了吗

gaominjie 发表于 2019-11-19 21:09

527664313 发表于 2018-4-21 09:47
朋友,你的dsp卡在InitSysCtrl()的问题解决了吗

我也卡在InitSysCtrl()了{:sweat:}

zuoanhuafeng 发表于 2019-11-22 08:47

看看时钟配置的对不对?
页: [1]
查看完整版本: dsp28335 initsysctrl()