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; } }
my program is read from EEPROM to the USB chip(CY7C68013) through I2C, which is download to the internal RAM of 8051 inside CY7C68013.
BYTE xdata AD0DATA[2048]; void TD_Init(void) // Called once at startup { CKCON=0x00; IT0=0; // EX0=0; //EX0=1 INT1 enable EA=1; CS=1; WR=1; RD=1; CONVST=1; for (ii=0;ii<2048;ii++) { EP2FIFOBUF[ii]=0; EP6FIFOBUF[ii]=0; AD0DATA[ii]=0; } AUTOPTRSETUP |= 0x01; // enable dual autopointer feature Rwuen = TRUE; // Enable remote-wakeup }
as i add the AD0DATA[ii]=0; in my program...it's showed me the USB device cannot be detected= =+ so...it means that...the array that i create have failed... but y??
EP2FIFOBUF[ii]=0; EP6FIFOBUF[ii]=0; AD0DATA[ii]=0;
Now, you have three different 2048 element long arrays. Where are the other arrays located, and of what data type?
But none of the code explains why you need to have your array at a specific location.
"so...it means that...the array that i create have failed... but y??"
How can you deduce that your array have failed. Exactly how can an array fail?
But you can have an almost infinite number of problems. Do you have valid contents in the EEPROM? Is your I2C code working. Is the USB code correct? The list can go on almost indefinitely. You just have to split your problem into smaller pieces, and verify them one by one.
actually, for not adding AD0DATA[ii]=0;into the loop everything is OK!!! and the EP2FIFOBUF and EP6FIFOBUF has a space for FIFO transfer, which is internally allocate there... that cmd is not a problem then.
If your program takes too long to boot, it may affect the initial USB handshake handling. So your array may work, but the time consumed by your loop may be enough for the failure.