📄 main.c
字号:
/************************************************************
* THIS PROGRAM IS PROVIDED "AS IS". TI MAKES NO WARRANTIES OR
* REPRESENTATIONS, EITHER EXPRESS, IMPLIED OR STATUTORY,
* INCLUDING ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE, LACK OF VIRUSES, ACCURACY OR
* COMPLETENESS OF RESPONSES, RESULTS AND LACK OF NEGLIGENCE.
* TI DISCLAIMS ANY WARRANTY OF TITLE, QUIET ENJOYMENT, QUIET
* POSSESSION, AND NON-INFRINGEMENT OF ANY THIRD PARTY
* INTELLECTUAL PROPERTY RIGHTS WITH REGARD TO THE PROGRAM OR
* YOUR USE OF THE PROGRAM.
*
* IN NO EVENT SHALL TI BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
* CONSEQUENTIAL OR INDIRECT DAMAGES, HOWEVER CAUSED, ON ANY
* THEORY OF LIABILITY AND WHETHER OR NOT TI HAS BEEN ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGES, ARISING IN ANY WAY OUT
* OF THIS AGREEMENT, THE PROGRAM, OR YOUR USE OF THE PROGRAM.
* EXCLUDED DAMAGES INCLUDE, BUT ARE NOT LIMITED TO, COST OF
* REMOVAL OR REINSTALLATION, COMPUTER TIME, LABOR COSTS, LOSS
* OF GOODWILL, LOSS OF PROFITS, LOSS OF SAVINGS, OR LOSS OF
* USE OR INTERRUPTION OF BUSINESS. IN NO EVENT WILL TI'S
* AGGREGATE LIABILITY UNDER THIS AGREEMENT OR ARISING OUT OF
* YOUR USE OF THE PROGRAM EXCEED FIVE HUNDRED DOLLARS
* (U.S.$500).
*
* Unless otherwise stated, the Program written and copyrighted
* by Texas Instruments is distributed as "freeware". You may,
* only under TI's copyright in the Program, use and modify the
* Program without any charge or restriction. You may
* distribute to third parties, provided that you transfer a
* copy of this license to the third party and the third party
* agrees to these terms by its first use of the Program. You
* must reproduce the copyright notice and any other legend of
* ownership on each copy or partial copy, of the Program.
*
* You acknowledge and agree that the Program contains
* copyrighted material, trade secrets and other TI proprietary
* information and is protected by copyright laws,
* international copyright treaties, and trade secret laws, as
* well as other intellectual property laws. To protect TI's
* rights in the Program, you agree not to decompile, reverse
* engineer, disassemble or otherwise translate any object code
* versions of the Program to a human-readable form. You agree
* that in no event will you alter, remove or destroy any
* copyright notice included in the Program. TI reserves all
* rights not specifically granted under this license. Except
* as specifically provided herein, nothing in this agreement
* shall be construed as conferring by implication, estoppel,
* or otherwise, upon you, any license or other right under any
* TI patents, copyrights or trade secrets.
*
* You may not use the Program in non-TI devices.
*************************************************************/
/************************************************************
* FILENAME: main.c
* DESCRIPTION: This example program uses McBSP1, DMA4
* and DMA5 of 'C5416 to read 2048 samples from the ADS8345
* 16-bit 100KSPS Analog-to-Digital Converter. The samples
* are stored by DMA5 in an array called buffer. When the
* DMA has transferred all 2048 samples it interrupts
* the CPU. At which point, the CPU disables all the
* perpherals and begins to sort the data by channel. All
* the samples read from analog input 0 are stored in
* Chan0, and likewise for the other 7 channels.
* Hardware Connections:
* ADC pin -> DSP pin
* CS# -> GPIO (assumed LOW)
* CLK -> CLKX1
* DIN -> DXR1
* DOUT -> DRR1
* BUSY -> FSR1 */
/*************************************************************/
/* AUTHOR: DAP Application Group, L. Philipose, Dallas */
/* CREATED 2002(C) BY TEXAS INSTRUMENTS INCORPORATED.*/
/* VERSION: 1.0 */
/*************************************************************/
/* Include DSPBIOS/CSL GUI configuration generated header file */
#include "c5416DMA_ads8345cfg.h"
/* Include files */
#include "ads8345.h"
#include <csl.h>
#include <csl_dma.h>
#include <csl_irq.h>
#include <csl_mcbsp.h>
#include <swi.h>
#include <log.h>
extern void ADC_init(void);
/* Global Variables*/
ioport unsigned int port1; /**/
/* Place buffer in its own section, since this must reside in DMA */
/* Memory Map. Check your device datasheet for valid ranges of */
/* DMA memory. */
//#pragma DATA_SECTION(buffer, "dmaMem")
extern Uint16 buffer[NSAMPLES];
//#pragma DATA_SECTION(CfgByte, "dmaMem1")
extern Uint16 CfgByte[NConfigWord]; /* A/D commands array */
/*************************************************************
*FUNCTION: main()
*DESCRIPTION: Function Initializes variables, enables
* peripherals and DMA5 interrupt.
**************************************************************/
void main()
{
Uint16 i=0;
/* Initialize CSL library, this step is required */
CSL_init();
port1 |=0x2; /*set ADC CS# high*/
while (i<=NSAMPLES) /*Initialize Data Table*/
{
buffer[i++]=0x0000;
}
/*Load A/D Configuration Word Array*/
CfgByte[0]=( START_BIT | CHAN0 | SGL_END_IN | NO_PDWN )<<8;
CfgByte[1]=( START_BIT | CHAN1 | SGL_END_IN | NO_PDWN )<<8;
CfgByte[2]=( START_BIT | CHAN2 | SGL_END_IN | NO_PDWN )<<8;
CfgByte[3]=( START_BIT | CHAN3 | SGL_END_IN | NO_PDWN )<<8;
CfgByte[4]=( START_BIT | CHAN4 | SGL_END_IN | NO_PDWN )<<8;
CfgByte[5]=( START_BIT | CHAN5 | SGL_END_IN | NO_PDWN )<<8;
CfgByte[6]=( START_BIT | CHAN6 | SGL_END_IN | NO_PDWN )<<8;
CfgByte[7]=( START_BIT | CHAN7 | SGL_END_IN | NO_PDWN )<<8;
port1 &=0xD; /*set ADC CS# low*/
ADC_init();
/*Start Recieve channel*/
DMA_start(hDma5);
/*Start Transmit channel*/
DMA_start(hDma4);
/* Prime MCBSP DXR */
while (!MCBSP_xrdy(hMcbsp1)){;}
MCBSP_write16(hMcbsp1,0x0000);
IRQ_enable(IRQ_EVT_DMAC5);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -