Keil Logo

C51: ABSOLUTE FAR VARIABLES DO NOT CALL IBANKING FUNCTIONS


Information in this article applies to:

  • C51 Version 7

QUESTION

I'm using far variables to access a Flash device in my application. Currently, I have a very simple test code that just tests my configuration. Here is my program:

#pragma VARBANKING

#include <absacc.h>


#define FLASH_BASE      0x80000
#define FlashCmdAddr1   FVAR(unsigned char, FLASH_BASE + 0x555)
#define FlashCmdAddr2   FVAR(unsigned char, FLASH_BASE + 0xAAA)
#define TEST_BYTE       FVAR(unsigned char, FLASH_BASE)

static void FlashCmd (
  unsigned char cmd,
  unsigned char far* addr)  {
  FlashCmdAddr1 = 0xaa;
  FlashCmdAddr2 = 0x55;
  *addr = cmd;
}

void main (void)  {
  while (1)  {
    FlashCmdSector (0xa0, &TEST_BYTE);
    TEST_BYTE = 1;
  }
}

The problem is the software does not call the ?C?CLDXPTR and ?C?CSTXPTR that are defined in the L51_BANK.A51 or XBANKING.A51 file. It seems the linker is loading C51L.LIB instead of C51BL.LIB.

How can I solve this problem?

ANSWER

Your assumption is correct. The linker does not use the variable banking library version.

You can solve this problem in two ways:

  1. The linker does not detect the variable banking library, since your program does not define any far variables. You can simply add one far variable to overcome the problem:
    unsigned char far dummy;  // force linker to use variable banking libraries.
    
  2. If you do not want to define a dummy variable, you may explicitly add the banking libraries to the project. If your application requires floating point arithmetic, you have to first add the C51BFPL.LIB and then the C51BL.LIB. If you do not use floating point numbers, just add the C51BL.LIB to the project file list of your project.

MORE INFORMATION

SEE ALSO

Last Reviewed: Monday, July 18, 2005


Did this article provide the answer you needed?
 
Yes
No
Not Sure
 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.