This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

2 Code bank with Single SRAM

Hello,
If we create 2 Banks for our project, for using more than 64K program.

1.We wanted to common SRAM for both the banks. Please describe how we can control the SRAM with 2 banks program;

2.When we create 2 banks for program; after compile; our SRAM getting dubbeld

Details:
>> We are using 89C51X2BN, with External EP-Rom Winbond 27C010-70, SRAM: 62-256

>> earlier we are using Franklin 3.2; (Dos Based Compiler) and we created 2 different Hex Files(1 Main Program and 2 Print Program)
with this our product working perfectly,) the same we did in Keil PK51)
The system start working but when we use 2 part program; and same time used 1 Part program > system goes hang)

After seen the Code banking on keil site, we did required correction; result our SRAM dubbeld.

Please guide us.

  • This may partly be a language problem, but your problem description is almost impossible to understand. You'll have to explain yourself more clearly before anybody can help you.

    1.We wanted to common SRAM for both the banks. Please describe how we can control the SRAM with 2 banks program;

    What do you think you have to "control" about that SRAM? What makes you believe you need different "control" in a banked program than in a traditional one?

    our SRAM getting dubbeld

    I have no idea what you're trying to tell us there. What exactly did you observe, and why did lead you to the conclusion that something was getting doubled?

    What I think you're doing there is that you're trying to roll your own code banking, without telling the Keil tools what you're doing. That can't work. You either have to use Keil's code banking scheme, or at least keep the tools informed about your non-standard actions.

  • I am sorry that I am unable to explain the problem:

    I wanted to explain once again from starting:

    1. Previously we are using Franklin 3.2 Ver, as our requirement is more that 64K code, thus we create a program in 2 Part.
    a. 1st part belongs to main program; we called Line20 files.
    b. 2nd part belongs to extension program; we called print20 files.

    2. For this we kept same variables for 2 different program files (Line20 & Print20)
    3. We compile separately both the program and program in our 27C010-70 ep-rom for target address.
    4. Our program running successfully.


    Now we purchase latest Keil PK51

    1. We did our old technique for both the program files "line20 & print20
    2. Same way we program into the ep-rom.
    3. System start working;
    4. we stuck up, when we gave a command for printing "accessing the print20 files, and doing On-Hook Off-Hook "accessing Line20 file.


    Now we seen the Keil site and found more details about code banking technique;

    1. We did as per guided technique.
    2. We found following error, thus our target file "hex" not created by PK51
    1. We create same variables for 2 different program files; same as explain in above"line20 & Print20
    2. When we compile using code bank technique, all the variables occupied double the Space in SRAM; thus object file "hex file not generated by PK51
    3. If we remove the variables in one file for checking, Getting error msg; "variable is not defined"

    Details about our Project:

    1. We are creating PABX system based on 8051
    2. We are using 89C51X2BN Micro controller and External ep-rom "Winbond 27C010"
    3. SRAM is Cy62C256
    4. 1st bank contains main program files or Online features of our PABX
    5. All printing command kept in the 2 bank program file, Print20





    Support required for following question.

    1. We wanted to create 2 banks program files, code size more than 64K.
    2. Installed only 1 SRAM 62C256 on board.
    3. Need to control from one SRAM by single program.
    4. Can we use same variable "which is defined in 1st bank code; or need to create once again for 2 bank files?
    5. getting error; if we removed variables from 2nd bank code files.

  • The fog is lifting, but only quite slowly. It would probably be easier if you described your problem using a minimal, but complete example program.

    Here's what I understand you've been doing:

    *) You've never actually used code banking until now --- what you had before was not one code-banked application, but two separately built programs, sharing their XDATA variables. This XDATA sharing was done by hand. If it worked, that was more by luck than by design.

    *) Doing the same thing with current PK51 crashed the program. My educated guess is that this is because your luck ran out --- the XDATA memory layout of separately compiled programs is unlikely to be the same any more.

    *) Your attempt to convert this into a single code-banking application failed. The most probable cause for this is that you don't know enough C to manage to actually share variables between different source files. You need to learn about the difference between a definition and a declaration of a C variable, and what header files are for. This is basic multi-source-file C programming knowledge --- if you don't know this, maybe you got the wrong job.

  • There are two kinds of banking supported by the Keil tools.

    One form of code banking is to create multiple independent 64KB code banks. The entire 64KB bank is swapped as a unit by the bank switching hardware. Some portion of the code, such as the interrupt vector table and interrupt handles, has to live in both banks so that the routines are always available to the processor.

    The other common form of banking is for the code address hardware to split the 64KB code space into two 32KB banks. The lower bank, from 0 to 7FFF is usually called the "common" bank, and is always mapped into the memory space. The upper 32KB, from 8000..7FFF, is decoded to different physical memory locations by some banking hardware. With this memory layout, the common bank does not need to be duplicated.

    Have you perhaps configured the tools for the 64K method of banking when you really want the 32K method?

  • "There are two kinds of banking supported by the Keil tools."

    What you describe is two kinds of code banking. There is also XDATA banking, which is an entirely separate thing - you can have banked code with non-banked data, non-banked code with banked data, or both!

    It sounds like the OP is actually using banked code and non-banked data, but is having trouble with the data?

  • Yes, I was speaking of code banking, which is indeed entirely different from data banking. Thanks for the clarification.

    I have to admit I'm not entirely clear on exactly what the OP's problem is. I got the impression that they were building "two programs" and thus that they were concerned with code banking. But it's quite possible that I misunderstood.

  • We are having 2 separate source file, both uses 60K common XDATA memory.

    Perversely we will compile both the files (line20 & print20) separately – at that time we are getting same XDATA address for both the files.

    That's why we can able to mange the program.

    Now we tried to use code banking with linking the both the files, so we declaring both the variables as external, after compiling, we are getting "ERROR PARSING SOURCE FILE"

    Support required:
    1. Any limit of external variables?
    2. Any limit of Macro definition?

  • "I have to admit I'm not entirely clear on exactly what the OP's problem is."

    I think we're all pretty baffled!

    "Perversely we will compile both the files (line20 & print20) separately..."

    Perverse is certainly the right word!

    I think Hans-Bernhard has probably managed to penetrate the fog the best so far. Like he says, it sounds like your original concept is not code banking at all - it's two entirely independant programs that just happen to be in the same ROM.

    "at that time we are getting same XDATA address for both the files."

    How do you know that? the Compiler does not assign addresses; this is only done by the Linker - unless you've defined every single variable using _at_...

    "Now we tried to use code banking with linking the both the files, so we declaring both the variables as external"

    No, that can't work - they can't both be external! You must have one of them define the data, and the other reference it via external declarations - as Hans-Bernhard said.

    You really need to stand back and get the principle right before trying it on this monster system (2x 60K in a single 8051!!):
    Write two very simple programs that share just a couple of variables, and get that working - something so simple that you can easily post the whole code here.
    Once you've got this working, you can go back to applying it to the big system

  • "I have to admit I'm not entirely clear on exactly what the OP's problem is."

    Me too!

    Perhaps it'd help if Sandeep explained what it is that he's actually trying to do?

    Why does he have two independent (apparently), very large programs that he's trying to load onto the same processor?

    Never mind implementation details (code banking, etc) what is the system actually supposed to do?

  • Perverse is certainly the right word!

    Well, I prefer to think he actually meant to say "previously", though ;->

    How do you know that? the Compiler does not assign addresses; this is only done by the Linker - unless you've defined every single variable using _at_...

    He said "at that time" --- by which he means eons ago, using C51 version 3.20. And he thinks he knows because the system appeared to work, back then.

    Now, if one really wanted to, I think one could still achieve that for separately compiled programs, even with the latest C51. You could do one of the following:

    * turn on the "keep variables in order" option in C51, and run an appropriately tuned 'diff' on the two map files, to check that it actually worked out

    * use LX51 options "PUBLICSONLY" and "MERGEPUBLICS" (currently only in the preliminary online manual, but not in any release notes???) to bound one program's definitions to the other program's declarations

    * Extract one program's public symbols from its map file, and transform them into _at_ declarations to be used by the other(s).

    But in the end of the day, I'm pretty sure that creating a properly banked application is a better overall plan.

  • Thanks, you understand me ;)

    We create 2 programs, and than compile it, map it, again compile it. :) and able to run the program.

    Any way we are working on PK51, and doing correction as required.

    support needed:

    Due to above 2 program is belong for one systems, now we wanted to correct the code and program as one hex into the ep-rom.

    if you have some tips, please let us know so we can fix the error fast.

  • Hello,

    We are able to compile our current code using code banking. after compiling PK51 generate 2 hex files for programming into the ep-rom.

    Now we stuck up in one more problem.

    1. We are using P89C51 with 4 K internal Flash. We wanted to keep very little code into the micro controller for security only. rest all code we wanted to keep in external Rom, and we don't wanted to modify the micro controller code, wanted to fix the code. When ever we upgrade the program we just reprogram the ep-rom;

    As per my programmer told that after using
    code banking; we are unable to create the separate file for micro controllers, we have to program microcontroller each time.

    We seen the bootloader example, but it is to complex, we wanted to keep very few of function in microcontroller.

    As seen to other products in our same line, they are also keeping Little code in microcontroller and rest all code in ep-rom.

    please suggest the solution.