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 #53 background imageLoading...
Page #53 background image
Traditional and Structure Approach to C Coding
Is the Structure Approach Efficient?
Is the Structure Approach Efficient?
(This example could not have been coded any more efficiently wit
(This example could not have been coded any more efficiently wit
h hand assembly)
h hand assembly)
The structure approach enables efficient compiler use of
The structure approach enables efficient compiler use of
DP addressing mode and C28x Atomic operations
DP addressing mode and C28x Atomic operations
C Source Code
C Source Code
// Stop CPU Timer0
// Stop CPU Timer0
CpuTimer0Regs.TCR.bit.TSS = 1;
CpuTimer0Regs.TCR.bit.TSS = 1;
// Load new 32
// Load new 32
-
-
bit period value
bit period value
CpuTimer0Regs.PRD.all = 0x00010000;
CpuTimer0Regs.PRD.all = 0x00010000;
// Start CPU Timer0
// Start CPU Timer0
CpuTimer0Regs.TCR.bit.TSS = 0;
CpuTimer0Regs.TCR.bit.TSS = 0;
Generated Assembly Code
Generated Assembly Code
MOVW DP, #0030
MOVW DP, #0030
OR @4, #0x0010
OR @4, #0x0010
MOVL XAR4, #0x010000
MOVL XAR4, #0x010000
MOVL @2, XAR4
MOVL @2, XAR4
AND @4, #0xffef
AND @4, #0xffef
5 Words, 5 cycles
5 Words, 5 cycles
-
-
Easy to read the code w/o comments
Easy to read the code w/o comments
-
-
Bit mask built
Bit mask built
-
-
in to structure
in to structure
Compare with the #define Approach
Compare with the #define Approach
The #define approach relies heavily on less
The #define approach relies heavily on less
-
-
efficient
efficient
pointers for random memory access, and often does not
pointers for random memory access, and often does not
take advantage of C28x atomic operations
take advantage of C28x atomic operations
C Source Code
C Source Code
// Stop CPU Timer0
// Stop CPU Timer0
*TIMER0TCR |= 0x0010;
*TIMER0TCR |= 0x0010;
// Load new 32
// Load new 32
-
-
bit period value
bit period value
*TIMER0TPR32 = 0x00010000;
*TIMER0TPR32 = 0x00010000;
// Start CPU Timer0
// Start CPU Timer0
*TIMER0TCR |= 0xFFEF;
*TIMER0TCR |= 0xFFEF;
Generated Assembly Code
Generated Assembly Code
MOV AL,*(0:0x0c04)
MOV AL,*(0:0x0c04)
ORB AL, #0x10
ORB AL, #0x10
MOV *(0:0x0c04), AL
MOV *(0:0x0c04), AL
MOVL XAR4, #3078
MOVL XAR4, #3078
MOVL XAR5, #65536
MOVL XAR5, #65536
MOVL *+XAR4[0], XAR5
MOVL *+XAR4[0], XAR5
MOV AL, *(0:0x0c04)
MOV AL, *(0:0x0c04)
OR AL, #0xffef
OR AL, #0xffef
MOV *(0:0x0c04), AL
MOV *(0:0x0c04), AL
9 Words, 9 cycles
9 Words, 9 cycles
-
-
Hard to read the code w/o comments
Hard to read the code w/o comments
-
-
User had to determine the bit mask
User had to determine the bit mask
C28x - Peripheral Registers Header Files 3 - 5

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