Skip to content Skip to navigation Skip to collection information

OpenStax_CNX

You are here: Home » Content » DSP Laboratory with TI TMS320C54x » Core File: Accessing External Memory on TI TMS320C54x

Navigation

Lenses

What is a lens?

Definition of a lens

Lenses

A lens is a custom view of the content in the repository. You can think of it as a fancy kind of list that will let you see content through the eyes of organizations and people you trust.

What is in a lens?

Lens makers point to materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

Who can create a lens?

Any individual member, a community, or a respected organization.

What are tags? tag icon

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

This content is ...

Affiliated with (What does "Affiliated with" mean?)

This content is either by members of the organizations listed or about topics related to the organizations listed. Click each link to see a list of all content affiliated with the organization.

Also in these lenses

  • Lens for Engineering

    This module and collection are included inLens: Lens for Engineering
    By: Sidney Burrus

    Click the "Lens for Engineering" link to see all content selected in this lens.

Recently Viewed

This feature requires Javascript to be enabled.

Tags

(What is a tag?)

These tags come from the endorsement, affiliation, and other lenses that include this content.
 

Core File: Accessing External Memory on TI TMS320C54x

Module by: Douglas L. Jones, Swaroop Appadwedula, Matthew Berry, Mark Haun, Dima Moussa, Daniel Sachs. E-mail the authors

Summary: Large amounts of data can be stored in external memory. The READPROG and WRITPROG macros copy data between internal memory and external memory.

Introduction

The TI DSP evaluation boards you use have a large amount of memory; in addition to the 32K words internal to the DSP, there are another 256K words of memory installed on the EVM board. For many exercises, the data sets are small, and you worked with only the on-chip memory of the DSP and were not expected to consider how the use of memory impacted performance. However, the large delays often required in audio processing, for example, require that many thousands of samples be stored in memory. There is not enough memory on the DSP microprocessor itself to store a second or more of samples at a 44.1 kHz sample rate, so the off-chip memory must be used.

EVM Memory Maps

As you have seen, the TI TMS320C54x DSP has two separate memory spaces, called Program and Data. Usually, Program contains your assembled program, and Data contains data, but sometimes it may be convenient or more efficient to violate this convention. (For instance, the firs instruction requires filter coefficients in the Program address space.) The Data space is 64K long and is accessed using the 16-bit auxiliary registers (ARx). Although the Program space is normally accessed using 16-bit literals stored in your program code, the Program space is, in fact, significantly larger than 64K. Using special "extended addressing" instructions, the TI DSP can access up to 8192K-words of memory in the Program space. The extended addressing instructions include far calls and jumps that reset the full 23-bit program counter, as well as accumulator-addressed data-transfer instructions.

Internal and external memory

In many exercises, it is possible to store program instructions and data entirely in the DSP's on-chip ("internal") memory. This internal memory has several advantages over off-chip ("external") memory: it is much faster (data stored can be accessed without delay), and multiple reads and writes can access the DSP's on-chip memory simultaneously. However, many applications (including the audio delay effect of Using External Memory) require a data buffer too large to fit into the on-chip memory. For these large buffers, we must use the larger but slower external memory.

When writing programs that require large amounts of memory, use the internal memory to hold your code, filter coefficients, and any small buffers you need. External memory should be used for large buffers that you only access a few times per sample, like the delay buffer described in Audio Effects: Using External Memory.

TMS320C549x DSP EVM memory maps

Figure 1: DSP EVM memory maps
Figure 1 (ram2.png)

As these memory maps show, the EVM's Data address space is addressed fully by the 16-bit auxiliary registers (ARx) and address-extension words and the mapping of Data memory is not affected by the OVLY bit. However, because the Program memory space is much larger than can be addressed by the 16-bit addressing register or the 16-bit literals stored in the program, it is split up into 64K (16-bit) pages by the hardware. Normal instructions, such as call, firs, and mvpd accept only 16-bit addresses, and can therefore only address the current "page" (usually address in the form 00xxxxh, which corresponds to the addresses the linker uses for your program's code). To access the full 23-bit address space, the DSP offers special accumulator-addressed load, store, and jump instructions.

Further complicating matters is the fact that the OVLY bit affects the mapping of the Program memory space. If you remember, before we load our DSP program, we have to change the PMST to FFE0h. We do this to set the OVLY bit in the PMST, which maps the internal memory into both the Program and Data spaces of the DSP. If OVLY is 1, the internal memory appears in both the Data and Program memory address space at locations 0080h to 07FFFh. Therefore, with OVLY set, anything written into Data memory below 07FFFh will overwrite a program stored in the same location. 1 In addition, copies of the internal memory also appear in the extended Program address space, occupying locations 0080h-7FFFh of each page. Therefore, with OVLY set, any addresses to Program memory locations in the form of xx0000h-xx7FFFh reference internal memory.

When OVLY is zero, internal memory is not mapped into the Program space at all; in this case, the Program space includes only external memory. In this mode, all 192K words of external Program RAM are accessible, although several wait states will be required for accessing each item of memory. In the overlay mode, only addresses in the ranges of 08000h-0FF00h, 1800h-1FFFFh, and 28000h-2FFFFh are available to store your data buffers; the remaining addresses are unmapped or map to the on-chip RAM.

To escape this confusion and allow the full 192K-words of external Program RAM to be used for your data buffers, the core file provides mechanisms for manipulating the PMST indirectly. Instead of accessing the external Program RAM directly, we can use the special macros to access the RAM that is normally "hidden" by the internal memory. This allows us to use the full range of external memory available: addresses 000000h-00FF00h and 010000h-02FFFF. However, since addresses 00FF00h-00FFFFh are reserved by the core file, you must be careful not to write to addresses in this range.

Accessing Extended Program RAM

The core file provides two macros for accessing data stored in the external Program RAM: READPROG and WRITPROG. These macros allow the processor to copy data between data memory and external Program memory. Both macros address external Program memory using the value in accumulator A. READPROG reads data from the external Program memory location pointed to by A and writes it to the data memory location pointed to by AR1. WRITPROG reads data from the memory location pointed to by AR1 and writes it to the location in external Program RAM specified by accumulator A. Both macros take one parameter, a count; specifying 1 reads or writes one word from external memory, and specifying some other number n n transfers n n words starting at the locations pointed to by A and AR1. AR1 is left pointing at the word after the last word read or written; no other registers are modified.

For instance, the following code fragment loads the value contained in memory location 023456h into the location 0064h in data memory using the READPROG macro:



	
	1    stm	#64h,AR1	; load 64h into AR1
	2    ld	#02h,16,A	; load 02h in high part of A
	3    adds 	#3456h,A	; fill in low part of A
	4				; A contains 023456h
	5	  READPROG 1 		; read from 023456h in external Program RAM
	6				; into *AR1 in Data RAM
	
      

The WRITPROG macro can be used similarly to write into extended Program RAM:



	      
	1   stm	#64h,AR1	; load 64h into AR1
	2	ld	#02h,16,A	; load 02h in high part of A
	3	adds	#3456h,A	; fill in low part of A
	4				; A contains 023456h
	5	WRITPROG	1	; write from *AR1 in Data RAM to
	6				; 023456h in external Program RAM
	
      

Note that Code Composer will not display or allow you to change the contents of the external Program RAM on the memory-dump or disassembly screen, though you can view or change it indirectly by watching the effects of the READPROG and WRITPROG macros on data memory.

Footnotes

  1. This is why the memory allocated for your program - 6000h-7FFFh - does not overlap with any of the space allocated for the data segments.

Collection Navigation

Content actions

Download:

Collection as:

PDF | EPUB (?)

What is an EPUB file?

EPUB is an electronic book format that can be read on a variety of mobile devices.

Downloading to a reading device

For detailed instructions on how to download this content's EPUB to your specific device, click the "(?)" link.

| More downloads ...

Module as:

PDF | EPUB (?)

What is an EPUB file?

EPUB is an electronic book format that can be read on a variety of mobile devices.

Downloading to a reading device

For detailed instructions on how to download this content's EPUB to your specific device, click the "(?)" link.

| More downloads ...

Add:

Collection to:

My Favorites (?)

'My Favorites' is a special kind of lens which you can use to bookmark modules and collections. 'My Favorites' can only be seen by you, and collections saved in 'My Favorites' can remember the last module you were on. You need an account to use 'My Favorites'.

| A lens I own (?)

Definition of a lens

Lenses

A lens is a custom view of the content in the repository. You can think of it as a fancy kind of list that will let you see content through the eyes of organizations and people you trust.

What is in a lens?

Lens makers point to materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

Who can create a lens?

Any individual member, a community, or a respected organization.

What are tags? tag icon

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

| External bookmarks

Module to:

My Favorites (?)

'My Favorites' is a special kind of lens which you can use to bookmark modules and collections. 'My Favorites' can only be seen by you, and collections saved in 'My Favorites' can remember the last module you were on. You need an account to use 'My Favorites'.

| A lens I own (?)

Definition of a lens

Lenses

A lens is a custom view of the content in the repository. You can think of it as a fancy kind of list that will let you see content through the eyes of organizations and people you trust.

What is in a lens?

Lens makers point to materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

Who can create a lens?

Any individual member, a community, or a respected organization.

What are tags? tag icon

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

| External bookmarks