Traditional and Structure Approach to C Coding
Traditional and Structure Approach to C Coding
Traditional Approach to C Coding
Traditional Approach to C Coding
#define ADCTRL1 (volatile unsigned
#define ADCTRL1 (volatile unsigned
int
int
*)0x00007100
*)0x00007100
#define ADCTRL2 (volatile unsigned
#define ADCTRL2 (volatile unsigned
int
int
*)0x00007101
*)0x00007101
...
...
void main(void)
void main(void)
{
{
*ADCTRL1 = 0x1234;
*ADCTRL1 = 0x1234;
//write entire register
//write entire register
*ADCTRL2 |= 0x4000;
*ADCTRL2 |= 0x4000;
//reset sequencer #1
//reset sequencer #1
}
}
Disadvantages
Disadvantages
-
-
Requires individual masks to be generated to
Requires individual masks to be generated to
manipulate individual bits
manipulate individual bits
-
-
Cannot easily display bit fields in Watch window
Cannot easily display bit fields in Watch window
-
-
Will generate less efficient code in many cases
Will generate less efficient code in many cases
Advantages
Advantages
-
-
Simple, fast and easy to type
Simple, fast and easy to type
-
-
Variable names exactly match register names (easy
Variable names exactly match register names (easy
to remember)
to remember)
Structure Approach to C Coding
Structure Approach to C Coding
void main(void)
void main(void)
{
{
AdcRegs
AdcRegs
.ADCTRL1.all = 0x1234;
.ADCTRL1.all = 0x1234;
//write entire register
//write entire register
AdcRegs
AdcRegs
.ADCTRL2.bit.RST_SEQ1 = 1;
.ADCTRL2.bit.RST_SEQ1 = 1;
//reset sequencer #1
//reset sequencer #1
}
}
Disadvantages
Disadvantages
-
-
Can be difficult to remember the structure names
Can be difficult to remember the structure names
(Code Maestro to the rescue!)
(Code Maestro to the rescue!)
-
-
More to type (again, Code Maestro to the rescue)
More to type (again, Code Maestro to the rescue)
Advantages
Advantages
-
-
Easy to manipulate individual bits.
Easy to manipulate individual bits.
-
-
Watch window is amazing! (next slide)
Watch window is amazing! (next slide)
-
-
Generates most efficient code (on C28x)
Generates most efficient code (on C28x)
C28x - Peripheral Registers Header Files
3 - 3
Summary of Contents for C28 Series
Page 64: ...Summary 3 16 C28x Peripheral Registers Header Files ...
Page 78: ...Interrupt Sources 4 14 C28x Reset and Interrupts ...
Page 218: ...Lab 9 DSP BIOS 9 22 C28x Using DSP BIOS ...
Page 244: ...Lab 10 Programming the Flash 10 26 C28x System Design ...
Page 273: ...Appendix A eZdsp F2812 C28x Appendix A eZdsp F2812 A 1 ...
Page 276: ...Appendix P2 Expansion Interface A 4 C28x Appendix A eZdsp F2812 ...
Page 277: ...Appendix P4 P8 P7 I O Interface C28x Appendix A eZdsp F2812 A 5 ...
Page 278: ...Appendix A 6 C28x Appendix A eZdsp F2812 ...
Page 279: ...Appendix P5 P9 Analog Interface C28x Appendix A eZdsp F2812 A 7 ...
Page 282: ...Appendix A 10 C28x Appendix A eZdsp F2812 TP1 TP2 Test Points ...