XC878 idata access always returns 0

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Not applicable
I'm using Keil µVision and my code works fine in the simulator, but on the µC idata access always returns 0. Is there something I have to do to get it to work? Note I'm not using the Keil boot assembly code.

This is my XDATA access code. I thought IDATA access to the memory range 0x80-0xFF should work out of the box, but it doesn't.

/**
* MEX3 XRAM Bank Number bits.
*
* Used to select the memory bank where the XRAM is located.
* This 4 bit field is divided, the highest bit goes into the BIT_MXB19 bit.
*/
#define BIT_MXB 0

/**
* MEX3 XRAM Bank Number bit count.
*/
#define CNT_MXB 3

/**
* MEX3 XRAM Bank Number highest bit.
*
* The final MXB bit.
*/
#define BIT_MXB19 4

/**
* The selected XRAM bank number.
*/
#define XRAM_BANK 0xF

/**
* MEX3 XRAM Bank Selector bit.
*/
#define BIT_MXM 3

/**
* Set BIT_MXM to access XRAM, the alternative would be banking mode, which
* would allow us to separate modules into their idividual memory spaces, but
* deprive us of the use of XRAM.
*/
#define XRAM_SELECTOR 1

/**
* Sets up xdata memory access.
*
* Refer to the Processor Architecture and Memory Organization chapters of the
* XC878 User Manual.
*/
void hsk_boot_mem(void) {
MEX3 = XRAM_SELECTOR << BIT_MXM \
| ((XRAM_BANK & ((1 << CNT_MXB) - 1)) << BIT_MXB) \
| ((XRAM_BANK >> CNT_MXB) << BIT_MXB19);
}


I'm hurting for the 128b of additional memory I could use with idata.
0 Likes
2 Replies
eugene
Employee
Employee
Hi kamikaze,

You're right that access to IDATA should be working. The MEX3 configuration is purely for accessing data in XDATA. It's not related to the issue that you have.

Without additional information, it's really hard for me to understand what's going on. Could you attach an example project that is causing the behaviour that you're observing ?

Best regards,
Eugene
0 Likes
Not applicable
I finally got back to working on this and currently I cannot reproduce the problem. Everything works fine.

Since the last time I updated µVision from 9.03 to 9.05. But I rather think I did something stupid with pointers, like declaring an idata pointer to a variable stored in xdata.
0 Likes