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

📄 example_28xad.c

📁 详细讲叙了DSP2812的AD转化
💻 C
字号:
//
//      TMDX ALPHA RELEASE
//      Intended for product evaluation purposes
//
//###########################################################################
//
// FILE:	DSP28_Example.c
//
// TITLE:	DSP28 CPU_Timer example program.
//
//###########################################################################
//
//  Ver | dd mmm yyyy | Who  | Description of changes
// =====|=============|======|===============================================
//  0.55| 06 May 2002 | S.S. | EzDSP Alpha Release
//  0.57| 27 May 2002 | L.H. | No change
//###########################################################################

// Step 0.  Include required header files
         // DSP28_Device.h: device specific definitions #include statements for
         // all of the peripheral .h definition files.
         // DSP28_Example.h is specific for the given example.  

#include "DSP28_Device.h"

unsigned int a1[16];
unsigned int a2=0;

// Prototype statements for functions found within this file.
interrupt void ad(void);

void main(void)
{

// Step 1. Initialize System Control registers, PLL, WatchDog, Clocks to default state:
        // This function is found in the DSP28_SysCtrl.c file.
	InitSysCtrl();

// Step 2. Initialize PIE vector table:
	// The PIE vector table is initialized with pointers to shell Interrupt 
        // Service Routines (ISR).  The shell routines are found in DSP28_DefaultIsr.c.
	// Insert user specific ISR code in the appropriate shell ISR routine in 
        // the DSP28_DefaultIsr.c file.

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

	// Initialize Pie Control Registers To Default State:
        // This function is found in the DSP28_PieCtrl.c file.
	InitPieCtrl();

	// Initialize the PIE Vector Table To a Known State:
        // This function is found in DSP28_PieVect.c.
	// This function populates the PIE vector table with pointers
        // to the shell ISR functions found in DSP28_DefaultIsr.c.
	InitPieVectTable();	
	

	EALLOW;	// This is needed to write to EALLOW protected registers
	PieVectTable.ADCINT=&ad;
	EDIS;   // This is needed to disable write to EALLOW protected registers
    

    InitAdc();

    // Enable INT1 
	IER |= M_INT1;
    // Enable global Interrupts and higher priority real-time debug events:
	
	EINT;   // Enable Global interrupt INTM
	ERTM;	// Enable Global realtime interrupt DBGM
	while(AdcRegs.ADC_ST_FLAG.bit.SEQ1_BSY==0)
		{			

			AdcRegs.ADCTRL2.bit.SOC_SEQ1=1;

		}
		
// Step 6. IDLE loop. Just sit and loop forever (optional):	
	for(;;)
	{
	
	}
} 	


// Step 7. Insert all local Interrupt Service Routines (ISRs) and functions here:	
	// If local ISRs are used, reassign vector addresses in vector table as
    // shown in Step 5

interrupt void ad(void)
{
	IFR=0x0000;
//	PieCtrl.PIEIFR1.all = 0;
	PieCtrl.PIEACK.all=0xffff;
	a2++;
	a1[0]=AdcRegs.RESULT0;
	a1[1]=AdcRegs.RESULT1;
	a1[2]=AdcRegs.RESULT2;
	a1[3]=AdcRegs.RESULT3;
	a1[4]=AdcRegs.RESULT4;
	a1[5]=AdcRegs.RESULT5;
	a1[6]=AdcRegs.RESULT6;
	a1[7]=AdcRegs.RESULT7;
	a1[8]=AdcRegs.RESULT8;
	a1[9]=AdcRegs.RESULT9;
	a1[10]=AdcRegs.RESULT10;
	a1[11]=AdcRegs.RESULT11;
	a1[12]=AdcRegs.RESULT12;
	a1[13]=AdcRegs.RESULT13;
	a1[14]=AdcRegs.RESULT14;
	a1[15]=AdcRegs.RESULT15;
	AdcRegs.ADC_ST_FLAG.bit.INT_SEQ1_CLR=1;
	AdcRegs.ADCTRL2.bit.SOC_SEQ1=1;
	EINT;
	
}

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

⌨️ 快捷键说明

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