Hi, I am developing a firmware for EZUSB FX based board. I am facing a small problem. I am not able to initialize a Global variable in my firmware. Even though I assign the global variable with 0 initial value, But the variable does not take that value. I am using SMALL memory model for my development. my declerations looks like this :- BYTE GlobalCount = 0; and in my sof() I am using this variable and updating it and reusing it again in next sof(). Please advise .. Rahul Gupta
#pragma NOIV // Do not generate interrupt vectors #include <ezusb.h> #include <ezregs.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #define DCM_SIZE 64 #define XBYTE ((unsigned char volatile xdata*) 0) extern BOOL GotSUD; extern BOOL Sleep; extern BOOL Rwuen; extern BOOL Selfpwr; BYTE Configuration; BYTE AlternateSetting; volatile BYTE glbISOCnt =0 ; volatile BYTE glbCnt=0; static BYTE glbCntW = 0; volatile BYTE iso_out_cnt =0; unsigned char *pBuffer; unsigned char *CntBuf; //----------------------------------------------------------------------------- // Task Dispatcher hooks //----------------------------------------------------------------------------- void TD_Init(void) // Called once at startup { USBIEN |= bmSOF + bmURES; INISOVAL = bmEP8; //+bmEP9; OUTISOVAL = bmEP8; IN8ADDR = 0x50; OUT8ADDR = 0x00; } void TD_Poll(void) // Called repeatedly while the device is idle { } BOOL TD_Suspend(void) // Called before the device goes into suspend mode { return(TRUE); } BOOL TD_Resume(void) // Called after the device resumes { return(TRUE); } //----------------------------------------------------------------------------- // Device Request hooks // The following hooks are called by the end point 0 device request parser. //----------------------------------------------------------------------------- BOOL DR_GetDescriptor(void) { return(TRUE); } BOOL DR_SetConfiguration(void) // Called when a Set Configuration command is received { Configuration = SETUPDAT[2]; return(TRUE); // Handled by user code } BOOL DR_GetConfiguration(void) // Called when a Get Configuration command is received { IN0BUF[0] = Configuration; EZUSB_SET_EP_BYTES(IN0BUF_ID,1); return(TRUE); // Handled by user code } BOOL DR_SetInterface(void) // Called when a Set Interface command is received { AlternateSetting = SETUPDAT[2]; return(TRUE); // Handled by user code } BOOL DR_GetInterface(void) // Called when a Set Interface command is received { IN0BUF[0] = AlternateSetting; EZUSB_SET_EP_BYTES(IN0BUF_ID,1); return(TRUE); // Handled by user code } BOOL DR_GetStatus(void) { return(TRUE); } BOOL DR_ClearFeature(void) { return(TRUE); } BOOL DR_SetFeature(void) { return(TRUE); } BOOL DR_VendorCmnd(void) { return(FALSE); } //----------------------------------------------------------------------------- // USB Interrupt Handlers // The following functions are called by the USB interrupt jump table. //----------------------------------------------------------------------------- // Setup Data Available Interrupt Handler void ISR_Sudav(void) interrupt 0 { GotSUD = TRUE; // Set flag EZUSB_IRQ_CLEAR(); USBIRQ = bmSUDAV; // Clear SUDAV IRQ } // Setup Token Interrupt Handler void ISR_Sutok(void) interrupt 0 { EZUSB_IRQ_CLEAR(); USBIRQ = bmSUTOK; // Clear SUTOK IRQ } void ISR_Sof(void) interrupt 0 { BYTE i = 0; BYTE h = 0 , l = 0; iso_out_cnt = 0; h = OUT8BCH; l = OUT8BCL; if (l) { iso_out_cnt = (WORD) h; iso_out_cnt <<= 8; iso_out_cnt += l; } iso_out_cnt = OUT8BCL; if (iso_out_cnt > 0) { glbISOCnt = iso_out_cnt; } if (iso_out_cnt) { } else { for (i=0;i<glbISOCnt;i++) { IN8DATA = glbCntW; } glbCntW = glbCntW + glbISOCnt; if (glbCntW == glbISOCnt * 4) { glbCntW = 0; } } EZUSB_IRQ_CLEAR(); USBIRQ = bmSOF; // Clear SOF IRQ } void ISR_Ures(void) interrupt 0 { EZUSB_IRQ_CLEAR(); USBIRQ = bmURES; // Clear URES IRQ } void ISR_Susp(void) interrupt 0 { Sleep = TRUE; EZUSB_IRQ_CLEAR(); USBIRQ = bmSUSP; } Along with these 2 files I am including ezusb.lib, USBJMP.obj, STATUP.A51, INIT.A51(provided by cypress). Rahul