You are here

Question about 8051 'xdata' not 'working' ... | Cypress Semiconductor

Question about 8051 'xdata' not 'working' ...

Summary: 2 Replies, Latest post by Paul Claessen on 05 Jan 2016 11:31 AM PST
Verified Answers: 1
Last post
Log in to post new comments.
Paul Claessen's picture
24 posts


I'm making a small modification to a project that appears to use various global variables declared as 'xdata'.

I added my own variable, that I return on an IN endpoint:

xdata BYTE test;

            test = 0xAB;
            EP1INBUF[0] = test;

            EP1INBC = 1;

If my windows app reads this endpoint, it reads the value '0'.
However, if I remove the 'xdata' declaration, my windows app DOES actually read '0xAB'.

What is going on here, and how do I make 'xdata' work? (This is stripped down code to show the issue, I need 'xdata' because I want to use EZUSB EEPROM routines that have 'BYTE xdata *dat' arguments.

~ Paul Claessen


ajai's picture
Cypress Employee
76 posts

one way to check is to make sure the SRAM is connected properly in your schematic. Since the variable maybe forced to stay in the external SRAM, failure may cause it get incorrect data. 

since its working when it is placed in the internal RAM, I am suspecting this. 


Paul Claessen's picture
24 posts

Thanks for your response.
I had a closer look at this, and noticed that the Keil uVision IDE, for some reason, placed xram at 0x4000. There simply is no memory at 0x4000 in an FX2LP. When I removed the settings for the external memory settings in the 'Target' tab and rebuilt, everything worked just fine.


Log in to post new comments.