Ucd3138 Reference Code - Texas Instruments UCD3138 Technical Reference Manual

Digital power supply controller
Hide thumbs Also See for UCD3138:
Table of Contents

Advertisement

www.ti.com
Example-2. Code Compiled for 32-BIS State: max( )
C program
int max(int x,int y)
{
return (x < y ? y : x):
}
32-bit assembly program
;*****************************************************************
;
function venner: $max
;*****************************************************************
$max:
.state16
BX pc
NOP
.state32
B _max
.text
.global _max
;*****************************************************************
;
function def: _max
;*****************************************************************
_max:
CMP A1, A2
MOVLE A1, A2
BX LR
Since sum( ) is a 16-bit function, its entry point is $sum. Because it was compiled for dual-state
interworking, an alternate entry point, _sum, located in a different section is included. All calls to sum( )
requiring a state change use the _sum entry point.
The call to max( ) in sum( ) references $max, because sum( ) is a 16-bit function. If max( ) were a 16-bit
function, sum( ) would call the actual entry point for max( ).
However, since max( ) is a 32-bit function, $max is the alternate entry point for max( ) and handles the
state change required by sum( ).
Note that the above description applies for CCS 3 up to CCS 3.3.38.
With CCS 6.x, the object code will have the same structure, but the functions all have underscore as their
first character whether they are in ARM or Thumb mode. The assembler knows the mode by the setting at
assembly time. This information is stored in the object file, and the linker actually inserts the code for
mode switching. It is no longer compiled around each function as in 3.3.

14.5.5 UCD3138 Reference Code

The UCD3138 reference code provided along with the EVMs (UCD3138PFCEVM-026,
UCD3138PSFBEVM-027, UCD3138LLCEVM-028, UCD3138HSFBEVM-029) is written in a way that the
program executes mostly in user mode and switches to privileged modes only if it needs to change
interrupt configuration or program the flash memory.
The reference code does not often switch between the ARM and Thumb mode. All parts of the code
except for the interrupt service routines are executed in Thumb mode in order to save valuable program
space.
The file load.asm contains the routines that are the very first part of the code getting executed when
control switches from ROM boot-loader to program flash that contains the application firmware.
In order to switch into Thumb mode the following assembly code is included inside the file load.asm.
;*------------------------------------------------------
;* CHANGE TO 16 BIT STATE
;*------------------------------------------------------
ADD r0, pc, #1
BX r0
SNIU028A – February 2016 – Revised April 2016
Submit Documentation Feedback
Copyright © 2016, Texas Instruments Incorporated
Dual-State Interworking
*
*
ARM7TDMI-S MPUSS
461

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents