General Comments Regarding C
EEL4744C: Microprocessor Applications
by Chris
To understand how to use the C programming language well takes practice. Even if you are familiar with high-level programming, I very strongly recommend that you thoroughly read through each of the following five documents, in the same order listed.
- Introduction to C programming (course lecture)
- Introductory tutorial on programming the ATXmega128A1U with C (course tutorial)
- Getting Started Writing C-code for XMEGA (Atmel tutorial)
- More on C Programming (course lecture)
- Creating, Simulating, and Emulating in Atmel Studio, last page
In addition, I very strongly recommend that you thoroughly understand how to map all things that we have done thus far in assembly to the C programming language, as well as reinforce this knowledge by creating as many meaningful programs for yourself as you can. Beyond the above, take note of the following requirements that we are imposing whenever programming in C:
- Compiler optimization must be turned off, unless otherwise noted (see last page within the Creating, Simulating, and Emulating in Atmel Studio document).
- Libraries (i.e., header and source files) must be used for each relevant system within the microcontroller, e.g., TC, EBI, etc. In other words, whenever functions and anything else pertinent are appropriate for some specific system, they must exist within a library dedicated to that system. (See the More on C Programming lecture.)
- The use of standard C functions, e.g., sprintf, printf, delay_ms, etc., is prohibited.
- All code written for homework and lab must utilize predefined macros, e.g., group configurations, bitmasks, etc. (see the Getting Started Writing C-code for XMEGA tutorial as well as the More on C Programming lecture), whenever applicable.
The two files, usart.c and usart.h, constitue an example library
(usart_c_library_examples.zip)
for the USART system. This example library is pretty basic, and could be much further extended, but this should give you a good start. (I haven't executed this version of the code in hardware, so if you believe there are any notable discrepancies, please let me know.) Remember that you are responsible for fully understanding all examples and code provided.
|