EasyManuals Logo

Texas Instruments C28 Series Student Guide

Texas Instruments C28 Series
342 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #326 background imageLoading...
Page #326 background image
Set up the Stack
Set up the Stack
The Stack
The Stack
The C/C++ compiler uses a
The C/C++ compiler uses a
stack to:
stack to:
Allocate local variables
Allocate local variables
Pass arguments to
Pass arguments to
functions
functions
Save the processor status
Save the processor status
Save the function return
Save the function return
address
address
Save temporary results
Save temporary results
The compiler uses the hardware
The compiler uses the hardware
stack pointer (SP) to
stack pointer (SP) to
manage the stack.
manage the stack.
SP defaults to 0x400 at reset.
SP defaults to 0x400 at reset.
The run
The run
-
-
time stack grows from
time stack grows from
low addresses to higher
low addresses to higher
addresses.
addresses.
Data Memory
Data Memory
64K
64K
0x400
0x400
SP
SP
(reset)
(reset)
.stack
.stack
4M
4M
Caller’s
Caller’s
local
local
vars
vars
Arguments
Arguments
passed on
passed on
stack
stack
Return
Return
address
address
Function
Function
return
return
addr
addr
Temp results
Temp results
The C28x has a 16-bit stack pointer (SP) allowing accesses to the base 64K of memory. The stack
grows from low to high memory and always points to the first unused location. The compiler
uses the hardware stack pointer (SP) to manage the stack. The stack size is set by the linker.
Setting Up the Stack
Setting Up the Stack
Boot.
Boot.
asm
asm
sets up SP to
sets up SP to
point at .stack
point at .stack
The .stack section has to
The .stack section has to
be linked into the low 64k
be linked into the low 64k
of data memory. The SP is
of data memory. The SP is
a 16
a 16
-
-
bit register and cannot
bit register and cannot
access addresses beyond
access addresses beyond
64K.
64K.
Stack size is set by the
Stack size is set by the
linker. The linker creates a
linker. The linker creates a
global symbol,
global symbol,
--
--
STACK
STACK
-
-
SIZE, and assigns
SIZE, and assigns
it a value equal to the size
it a value equal to the size
of the stack in bytes.
of the stack in bytes.
(default 1K words)
(default 1K words)
You can change stack size
You can change stack size
at link time by using the
at link time by using the
-
-
stack linker command
stack linker command
option.
option.
Linker command file:
Linker command file:
SECTIONS {
SECTIONS {
.stack :>
.stack :>
RAM
RAM
align=2
align=2
... }
... }
Note: The compiler provides no
Note: The compiler provides no
means to check for stack
means to check for stack
overflow during compilation or at
overflow during compilation or at
runtime. A stack overflow
runtime. A stack overflow
disrupts the run
disrupts the run
-
-
time
time
environment, causing your
environment, causing your
program to fail. Be sure to allow
program to fail. Be sure to allow
enough space for the stack to
enough space for the stack to
grow.
grow.
In order to allocate the stack the linker command file needs to have “align = 2.”
D- 4 C28x – C Programming

Table of Contents

Other manuals for Texas Instruments C28 Series

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Texas Instruments C28 Series and is the answer not in the manual?

Texas Instruments C28 Series Specifications

General IconGeneral
BrandTexas Instruments
ModelC28 Series
CategoryComputer Hardware
LanguageEnglish

Related product manuals