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; } }
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.