ARM Technical Support Knowledge Articles

GETTING THE CURRENT BANK NUMBER

Applies to: C51 C Compiler

Answer


Information in this article applies to:


QUESTION

I'm using code banking with the BL51 code banking linker and I need to find the current code bank. How can I find this out?

ANSWER

You must add the following function to the end of the L51_BANK.A51 configuration file.

PUBLIC  get_bank
get_bank:

        MOV     A, ?B_CURRENTBANK
        ANL     A, #?B_MASK

REPT    ?B_FIRSTBIT
        RR      A
        ENDM

        MOV     R7, A
        RET

This function returns the current code bank. To access it in C, add a function prototype as follows:

extern unsigned char get_bank (void);

and use this function in your program as follows:

printf ("We're in code bank %u
", (unsigned) get_bank ());

SEE ALSO

Article last edited on: 2008-04-06 19:43:38

Rate this article

[Bad]
|
|
[Good]
Disagree? Move your mouse over the bar and click

Did you find this article helpful? Yes No

How can we improve this article?

Link to this article
Copyright © 2011 ARM Limited. All rights reserved. External (Open), Non-Confidential