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

📄 ads8364_main.c

📁 Interfacing the ADS8364 to the TMS320F2812 DSP
💻 C
字号:
/************************************************************/
/* FILENAME: ADS8364_MAIN.c                            		*/
/* DESCRIPTION: This program uses the parallel interface to */
/*	read 512 samples continuously from the ADS8364 16-bit   */
/* 500KSPS Analog-to-Digital Converter.  The samples are    */
/* stored in buffers.                                		*/             
/* AUTHOR	: DAP Application Group, T. Hendrick, Dallas    */
/*    CREATED 2002(C) BY TEXAS INSTRUMENTS INCORPORATED.  	*/
/* VERSION: 1.0 							                */
/************************************************************/
#include "DSP28_Device.h"
#include "DSP28_Globalprototypes.h"
#include "ADS8364_2812.h"

#define DEBUG 0

// Prototype statements for functions found within this file.
void delay_loop(int count);
void read_ADD(void);

void main(void)
{
// Channel pointers - channels are defined in ADS8364_2812.h
	ptrCHA0 = (int *)CHA0;
	ptrCHA1 = (int *)CHA1;
	ptrCHB0 = (int *)CHB0;
	ptrCHB1 = (int *)CHB1;
	ptrCHC0 = (int *)CHC0;
	ptrCHC1 = (int *)CHC1;

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

// Select GPIO for the device or for the specific application:
    InitGpio();   

// Hardware Reset the ADS8364:
	ResetADS8364();
	ADC_ready = 1;
	#if !ADD
    GpioDataRegs.GPFCLEAR.all = 0x0004;  // Set ADD Pin High
    #else
    GpioDataRegs.GPFSET.all = 0x0004;  // Clear ADD pin	
	#endif

    // 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();    
    
// User specific functions, Reassign vectors, Enable Interrupts, etc:
    XIntruptRegs.XINT1CR.all = 0x0001;
	XIntruptRegs.XINT2CR.all = 0x0001;

	PieCtrlRegs.PIEIER1.bit.INTx3 = 1;	// Enable WAKEINT (LPM/WD) in PIE group #1
	PieCtrlRegs.PIEIER1.bit.INTx4 = 1;	// Enable WAKEINT (LPM/WD) in PIE group #1

	IER |= 0x0001;

    // Enable global Interrupts:
	EINT;   // Enable Global interrupt INTM

    // Start the Conversion Clock
	PWM();  //ConvCLK from PWM1

while(1) // Forever Loop
	{
// Check initially for RESET, then after each read
		if (DEBUG)
		{	delay_loop(200);
			read_ADD();		}

		if (ADC_ready)
		{
		ToggleHOLDx(HOLDall);
		ADC_ready = 0;
		}
	}
}     


// Read Function called from ISR in ADS8364_DefaultISR.c
/*******************************************************************************
 FUNC	: read_ADD
 DESC	: Prepare the system for the ADC conversions. Everything is set up to
 		  wait the CONV CLK start running (TIMER0)
 ARGS	: void
 RET	: void
 *******************************************************************************/
void read_ADD()
{
	if (ADD_Mode){ADC_address[0] = (*ptrCHA0);}
	    CHA0_Data[idx] = *ptrCHA0;

	if (ADD_Mode){ADC_address[1] = (*ptrCHA1);}
	    CHA1_Data[idx] = *ptrCHA1;

	if (ADD_Mode){ADC_address[2] = (*ptrCHB0);}
	    CHB0_Data[idx] = *ptrCHB0;

	if (ADD_Mode){ADC_address[3] = (*ptrCHB1);}
	    CHB1_Data[idx] = *ptrCHB1;

	if (ADD_Mode){ADC_address[4] = (*ptrCHC0);}
	    CHC0_Data[idx] = *ptrCHC0;

	if (ADD_Mode){ADC_address[5] = (*ptrCHC1);}
	    CHC1_Data[idx] = *ptrCHC1;

	idx = idx+1;
	ADC_ready = 1;	
	if(idx == Samples){
	idx = 0;  //Insert probe point here to update display
	}
}

// Some Useful local functions
void delay_loop(int count)
{
    long      i;
    for (i = 0; i < count; i++) {}
}

//===========================================================================
// End Program.
//===========================================================================

⌨️ 快捷键说明

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