下面是用TMS470R1B1M的EBM接口读取ADS8548的程序,
其中这两句是我以前CCS3.0写DSP用的在这里编译不了,请帮帮我,51前要交货
//ioport unsigned 0x00300000; // 定义I/O口地址变量
//#define ADS8548_CS 0x00300000 // 定义字符标识ADS8548_CS等于I/O口地址0x00300000
#include <intrinsics.h>
#include <TexasInstruments/iotms470r1b1m.h>
#include <TexasInstruments/tms470r1B1m_bit_definitions.h>
long signed int Channel_1; // Channe1 AD采样数据,有符号整数
long signed int Channel_2; // Channe2 AD采样数据,有符号整数
long signed int Channel_3; // Channe3 AD采样数据,有符号整数
long signed int Channel_4; // Channe4 AD采样数据,有符号整数
long signed int Channel_5; // Channe5 AD采样数据,有符号整数
long signed int Channel_6; // Channe6 AD采样数据,有符号整数
long signed int Channel_7; // Channe7 AD采样数据,有符号整数
long signed int Channel_8; // Channe8 AD采样数据,有符号整数
long signed int Channel;
//ioport unsigned port4001; // 定义I/O口地址变量
//#define ADS8548_CS 0x00300000 // 定义字符标识AD656_data等于I/O口地址0x0002
//signed int ADS8548[24];
//char j, i,m;
extern char adflag ;
void SPI1_irq_handler();
void GIOB_irq_handler();
//extern signed int AD_data[8]={0,0,0,0,0,0,0,0};
signed int data[8] ;
long signed int temp[8] ;
//extern signed int sampledata[8];
unsigned int s ;
void init_ADS8548(void)
{
// Added to the main routine to setup the EBM registers for Writing
EBMCR1=0x02; // EBM Control register 1 set for 16 bit Data
EBRWCR=0x0F; // EBM Read/Write Control Register
// 7 = EBHOLD = 0 = The HOLD not mapped to an external device
// 6:3 = EBCS = 1111 = Chip Selects mapped to the Mux Output
// 2:1 = EBWR = 11 = The Write Enable bits mapped to the Mux Output
// 0 = EBOE = 1 = The Output Enable bit mapped to the Mux Output
//The next four Registers Map Addresses [29:0] to the Mux Output
EBACR1=0x3F; // EBM Address Control Register [5:0]
// 7:6 = EBWR = 00 = The Write Enables not mapped to the Mux Output
// 5:0 = EBADDR = 11111 = The Address Lines are mapped to the Mux Output
EBADCR=0xFF; // EBM Address/Data Control Register
// Address Lines D13:D6 are Mapped to the Mux Output
EBACR2=0xFF; // EBM Address Control Register [21:14]
// 7:0 = EBADDR[21:14] = 0x1F = The address Lines mapped to Mux Output
EBACR3=0x07; // EBM Address Control Register [29:22]
// 7:0 = EBADDR[29:22] = The address Lines mapped to the Mux Output
//The next Register Maps the 8 bit Data to the Mux Output
EBDCR=0xFF; // EBM Data Control Register D7:D0
// Data Lines D7:D0 are Mapped to the Mux Output
// added to the low level init file with the memory mapping code
// activate Expansion bus at 0x00500000 set size to 512KB
//MCBAHR2 = 0x0050; //EBM RAM base addr at 0x00500000
//MCBALR2 = 0x0050; // Size of 512KB
//Bits 7:4 control the wait states therefore only 0xF wait states are available.
//Choose only one of the following for generating internal Wait States.
// SMCR5 = 0x0004; //8-bit data width/External/Big Endian/1 wait states
// SMCR5 = 0x0014; //8-bit data width/External/Big Endian/1 wait states
// SMCR5 = 0x0024; //8-bit data width/External/Big Endian/2 wait states
// SMCR5 = 0x0034; //8-bit data width/External/Big Endian/3 wait states
// SMCR5 = 0x0044; //8-bit data width/External/Big Endian/4 wait states
MCBAHR2 = 0x0030; //EBM RAM base addr at 0x00300000
MCBALR2 = 0x0020; //Size of 64k
MFBALR0 = 0x0100; //Enable the memory map
SMCR5 = 0x35; //16-bit data width/External/Big Endian/3 wait states
EBDMACR = 0x01;
// EBRWCR = 0x0F;
//EBACR1 = 0x3F;
//EBDCR = 0xFF;
// EBADCR = 0xFF;
// EBACR2 = 0xFF;
// EBACR3 = 0x07;
// EBMCR1 = 0x02;
}
void StartSampling(signed int sampledata[])
{
for(j=0; j<8; j++)
{
for(i=0; i<30; i++)
{asm("nop");}
ADS8548[j] = ADS8548_CS ;
}
if(j=7) // m是从0开始取 ,取到11,这个地方我感觉要改成11,不是12。
{
//第一个数
Channel_1 = ADS8548[0] ;
// 第二个数
Channel_2 = ADS8548[1];
//第三个数
Channel_3 = ADS8548[2];
//第四个数
Channel_4=ADS8548[3];
//第五个数
Channel_5=ADS8548[4];
//第六个数
Channel_6 = ADS8548[5];
//第七个数
Channel_7=ADS8548[6];
//第八个数
Channel_8=ADS8548[7];
temp[0]=temp[0]+Channel_1;
temp[1]=temp[1]+Channel_2;
temp[2]=temp[2]+Channel_3;
temp[3]=temp[3]+Channel_4;
temp[4]=temp[4]+Channel_5;
temp[5]=temp[5]+Channel_6;
temp[6]=temp[6]+Channel_7;
temp[7]=temp[7]+Channel_8;
}
if( s > 400)
{
for(i=0;i<8;i++)
{
data[i]=temp[i]/s;
sampledata[i]=data[i];
}
for(i=0;i<8;i++)
{
temp[i]=0;
}
s = 0;
}
s++;
}