Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
28
Добавлен:
27.04.2015
Размер:
193.69 Кб
Скачать

SPRA366

Accessing Memory-mapped Registers

TIP: (C2x/ C2xx, C5x,C54x) Prefer C- macros or "asm" statements versus pointers to access memory-mapped registers. Using pointers to access memory-mapped registers forces the compiler to create extra space to store the address and extra cycles to load ARn for addressing. Using macros saves one cycle and two words of memory (one in data space for storing the address and one in program memory for nop instruction) due to the capabilities for storage of immediate operands. This can be seen in the following C54x example:

Using volatile pointers: (worse)

volatile unsigned *SPC0 = (unsigned *)0x22;*SPC0 = 0x0000;

Generates:

MVDM *(_SPC0),AR1 nop

ST #0,*AR1

===> 5 words

Using macro-defined pointers: (better)

#define SPC0 (volatile unsigned *)0x22 *SPC0 = 0x0000;

Generates:

STM #34,AR1

ST #0,*AR1

===> 4 words

Using asm statement: (best)

extern volatile unsigned SPC0; asm("_SPC0 .set 0x22"); SPC0 = 0x0000;

Generates:

ST #0,*(_SPC0)

The reference to _SPC0 is resolved correctly at assembly time.

===>3 words

C3x: C pointers is an efficient method to access memory-mapped registers due to the well-supported ARn indirect addressing mode.

Generating Efficient Code with TMS320 DSPs: Style Guidelines

23

Соседние файлы в папке TMS 320