External FLASH memory to store all the code.

Question: My design uses external FLASH memory to store all the code. I am using the default frameworks code that comes on the development CD, and my device is not coming up when I plug in the USB cable. What could be happening?  My firmware works on the dev board and my new device comes up?

 

Answer:

Please replace the following similar code snippet in frameworks with this one, only if you are using external memory for code boot up (EA=1). This will ensure that your descriptor table is located into internal memory properly. Previously the descriptors were nabbed from xdata space and NOT code space.


IntDescrAddr = INTERNAL_DSCR_ADDR;

ExtDescrAddr = (WORD)&DeviceDscr;

DevDescrLen = (WORD)&UserDscr - (WORD)&DeviceDscr + 2;

for (i = 0; i < DevDescrLen; i++)

*((BYTE xdata *)IntDescrAddr+i) = 0xCD;

for (i = 0; i < DevDescrLen; i++)

*((BYTE xdata *)IntDescrAddr+i) = *((BYTE code *)ExtDescrAddr+i);

pDeviceDscr = IntDescrAddr;

offset = (WORD)&DeviceDscr - INTERNAL_DSCR_ADDR;

pConfigDscr -= offset;

pHIDDscr -= offset;

pReportDscr -= offset;

pStringDscr -= offset;