⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rtdx_829_2.c

📁 利用ccs环境、MATLAB环境、DSP(TMS320F2812)、被测对象和Agilient网络分析仪E5071B
💻 C
字号:
#include <stdio.h>         
#include "DSP28_Device.h"          /* fprintf(), puts()        */
#include <stdlib.h>                     /* abort()                  */
#include <rtdx.h>                       /* RTDX                     */
#include "target.h"                     /* TARGET_INITIALIZE()      */

/* Declare and initialize an output channel called "ochan"          */
RTDX_CreateOutputChannel(ochan);
RTDX_CreateInputChannel(ichan);
void main( void )
{
 unsigned int idle[3]={11, 22, 33} ;

        unsigned int i,j;
		unsigned int command;
	InitSysCtrl();             //必要时,需要修改其中的相关寄存器配置,在使用时需查看;配置是否满足需求			
   

//////////////////////////////////////////////////////////////////
// Initializing GPIO
	EALLOW;
	GpioMuxRegs.GPAMUX.all=0xffff; // 配置端口A,作为PWM clock和GPIO
	GpioMuxRegs.GPADIR.all=0xffff;
	GpioMuxRegs.GPAQUAL.all=0x0000;
	GpioMuxRegs.GPEMUX.all=0x0003; // 配置端口E为外部中断XINT1,XINT2
	GpioMuxRegs.GPEDIR.all=0x0003;
	GpioMuxRegs.GPEQUAL.all=0x0000;
	GpioMuxRegs.GPFMUX.all=0x0000; 
	GpioMuxRegs.GPFDIR.all=0x0005;
	EDIS;
// GPIO Initialized OK !!!
///////////////////////////////////////////////////////////////////

//// Interrupt Control and Initializing ///////////////////////////
	DINT;
	IER=0x0000;
	IFR=0x0000;
 
	InitPieCtrl();
	InitPieVectTable();

 	XIntruptRegs.XINT1CR.all=0x0001; // 允许外设中断,触发方式为负边沿
	XIntruptRegs.XINT2CR.all=0x0001;

	PieCtrl.PIEIER1.bit.INTx3=1;
	PieCtrl.PIEIER1.bit.INTx4=1;
	IER|=0x0001;

	EINT;
//// Interrupt configured OK !!!
////////////////////////////////////////////////////////////////////


// GENERATE SQUARE SIGNAL: configure the T1 PR

	EvaRegs.T1PR=0x0012;	 // Timer1 period
	EvaRegs.T1CMPR=0x0008;	 // Timer1 compare
	EvaRegs.T1CNT=0x0000;	//Timer1 counter
	EvaRegs.T1CON.all=0x9042; 

 	EvaRegs.GPTCONA.all=0x0042;
////////////////////////////////////////////////////////////////////

        TARGET_INITIALIZE();
		RTDX_Init();
        RTDX_enableOutput(&ochan);
		RTDX_enableInput(&ichan);
 
 while(1)
 {

                // posting a idle to the pc

                if ( !RTDX_write( &ochan, &idle, sizeof(idle) ) ) 
                {
                        fprintf(stderr,

                                "\nError:%d RTDX_write() failed!\n",i);

                         abort();
                }

                                     
        /*        while ( RTDX_writing != NULL ) 
                {
                        #if RTDX_POLLING_IMPLEMENTATION
                               
                                RTDX_Poll();
                        #endif
                }    */
				// idle write ok
              
			    // receiving the command from the pc
			     
                if ( (RTDX_read( &ichan, &command, sizeof(command) )) != sizeof(command))
                 { 
                        fprintf(stderr,"\nError: RTDX_read() failed\n");
                        abort();
                  }
				else 
/*				for (j=0;j<10;j++)
				{
				fprintf(stdout,"recvd[%d]=%d",j,recvd[j]);
				}
				*/
					fprintf(stdout,"command=%d",command);
				fprintf(stdout,"\n");
 }



        RTDX_disableOutput(&ochan);   
		while(1)
		{
		}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -