since my topic use CY7C68013+AD7934+EEPROM as directly convert an analog signal to digital and send back to PC, but for the sampling rate of 10kHz, i want to have a buffer for me to save those data...and i have tried a lot of ways for opening a large array in KeilC... but most of the time it's not access... can someone else tell me how to create it... and i would wonder ask... can i allocate it @ fx2reg.h? and how to finish it up?
one of my unsuccess way...
CODE:
#pragma NOIV #include "fx2.h" #include "fx2regs.h" #include "fx2sdly.h" // SYNCDELAY macro extern BOOL GotSUD; // Received setup data flag extern BOOL Sleep; extern BOOL Rwuen; extern BOOL Selfpwr; BYTE Configuration; // Current configuration BYTE AlternateSetting; // Alternate settings #define VR_NAKALL_ON 0xD0 #define VR_NAKALL_OFF 0xD1 #define WB IOD_0 #define CS IOD_1 #define RD IOD_2 #define WR IOD_3 #define CONVST IOD_4 #define BUSY IOD_5 #define ALLOCATE_EXTERN #define START_MEM01 0x1e00 #define LENGTH_MEM01 0x200 BYTE xdata *AD0DATA[]= START_MEM01; void ad0(void); void TD_Init(void) // Called once at startup { . . . } void ad0(void) { . . . AD0DATA[count] = IOA; AD0DATA[count+1]= (IOB & 0x0f); } void T0int(void) //----timer 0 int----// { CS=1; WR=1; CONVST=1; OEA=0xff; OEB=0xff; TL0=0x0c; TH0=0xfe; if (count < 1023) count+=2; else { count=0; TR0=0; } ad0(); } void TD_Poll(void) { unsigned int i=0,j=0,loop=0; if(!(EP01STAT & 0x02)) //PC TO USB { if(EP1OUTBUF[0]==0x05) // Continous sampling and Sent to PC // { freq=(EP1OUTBUF[2]<<8)+EP1OUTBUF[1]; cycle=(EP1OUTBUF[4]<<8)+EP1OUTBUF[3]; SYNCDELAY; EP1OUTBC=0x05; // 5bytes data already be read SYNCDELAY; flag=1; count=0; TMOD=0x01; TL0=0x0c; TH0=0xfe; TR0=1; ET0=1; SYNCDELAY; times=0; while( times < cycle ) { if(!(EP2468STAT & bmEP6FULL)) { j=0; for(i=0;i<64;i++) { EP6FIFOBUF[j]=AD0DATA[j]; EP6FIFOBUF[j+1]=AD0DATA[j+1]; j+=2; } EP6BCH = 0x00; SYNCDELAY; EP6BCL = 0x80; // arm EP6IN SYNCDELAY; } }
i am now using BYTE xdata AD0DATA[2048]; thx
You really need to go back and lay some solid foundations for all this!
8051 Tutorial: http://www.8052.com/tutorial
The so-called "bible" for the 8051 - links here: www.8052.com/.../120112
The Keil C51 Manuals: http://www.keil.com/support/man_c51.htm
In particular: Memory Areas: http://www.keil.com/support/man/docs/c51/c51_le_memareas.htm
Memory Types: http://www.keil.com/support/man/docs/c51/c51_le_memtypes.htm
Memory Models: http://www.keil.com/support/man/docs/c51/c51_le_memmodels.htm
i have read those statement before... but i still can't find out how to solve it up...
halo, andy neil I HAVE SOLVED MY PROBLEM BY SETTING SOME FEATURES OF CY7C68013,WHICH CAN DIRECTLY USING
#define ALLOCATE_EXTERN
@fw.c TO directly allocate a memory address for me to work but, some question about the xdata, is that it must use a external 64K EEPROM or RAM to access that memory? i read through the datasheet but i did not understand it very well, can u give me some conclusion about that? thx a lot!!! AnthonyZ