ARM Technical Support Knowledge Articles

INDIRECTLY ACCESSING SFRS

Applies to: C166 C Compiler

Answer


Information in this article applies to:


QUESTION

Is it possible to indirectly access SFRs on the C16x/ST10 devices?

ANSWER

Yes. This is possible and may make some programming tasks easier.

For example, the following program provides an alternative way to access the CC0, CC1, and CC2 SFRs using an array.

/* Declare the standard CC0 SFR (for comparison) */
sfr CC0 = 0xFE80;

/* Declare a pointer to CC0 */
unsigned int *CC = (void *) 0xFE80;

void main (void)
{
/* Write to the CC0 SFR */
CC0 = 0x1234;

/* Access elements of the CC pointer as an array */
CC[0] = 0x5678;
CC[1] = 0x1414;
CC[2] = 0x2222;
}

The code generated for this example is as follows:

; FUNCTION main
; line 8: {
; line 9: CC0 = 0x1234;
        MOV     CC0,#4660
; line 10:
; line 11: CC[0] = 0x5678;
        MOV     R5,#22136
        MOV     R4,WORD CC
        MOV     [R4],R5
; line 12: CC[1] = 0x1414;
        MOV     R5,#5140
        MOV     R4,WORD CC
        MOV     [R4+#2],R5
; line 13: CC[2] = 0x2222;
        MOV     R5,#8738
        MOV     R4,WORD CC
        MOV     [R4+#4],R5
; line 14: }
        RET

Article last edited on: 2001-02-14 00:00:00

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