EasyManuals Logo
Home>Texas Instruments>Microcontrollers>C2000

Texas Instruments C2000 Workshop Guide And Lab Manual

Texas Instruments C2000
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 #45 background imageLoading...
Page #45 background image
Traditional and Structure Approach to C Coding
C2000 Microcontroller Workshop - Peripheral Registers Header Files 3 - 3
Traditional and Structure Approach to C Coding
Traditional Approach to C Coding
#define ADCCTL1 (volatile unsigned int *)0x00007100
...
void main(void)
{
*ADCCTL1 = 0x1234; //write entire register
*ADCCTL1 |= 0x4000; //enable ADC module
}
Disadvantages - Requires individual masks to be generated to
manipulate individual bits
- Cannot easily display bit fields in debugger window
- Will generate less efficient code in many cases
Advantages - Simple, fast and easy to type
- Variable names exactly match register names (easy
to remember)
In the traditional approach to C coding, we used a #define to assign the address of the register and
referenced it with a pointer. The first line of code on this slide we are writing to the entire
register with a 16-bit value. The second line, we are ORing a bit field.
Advantages? Simple, fast, and easy to type. The variable names can exactly match the register
names, so it's easy to remember. Disadvantages? Requires individual masks to be generated to
manipulate individual bits, it cannot easily display bit fields in the debugger window, and it will
generate less efficient code in many cases.

Table of Contents

Other manuals for Texas Instruments C2000

Questions and Answers:

Question and Answer IconNeed help?

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

Texas Instruments C2000 Specifications

General IconGeneral
BrandTexas Instruments
ModelC2000
CategoryMicrocontrollers
LanguageEnglish

Related product manuals