Developing in C on the AVR ATmega328P
Introduction
While the Arduino tool set, (both the Arduino IDE and Arduino software framework) are outstanding for quickly developing a working prototype, they do so with a combination of a graphical-user-interface (GUI), the C++ language and Arduino-only classes. This in itself, isn’t a problem, one can be quite efficient and productive using this approach.
This approach is an issue if you are at a university or job which expects a standards-based C language proficiency. It is also an issue, if your class or job, requires understanding how to use command-line-interface (CLI)-based tools. The C language, and not C++, is the basis of a significant number of embedded systems development.
This set of entries are written to help you learn how develop embedded ANSI C programs for the AVR family and specifically the ATmega328P (Arduino Uno R3). While doing so, it will also use a set of tools which can serve as the basis of an intermediate-level software programmer.
Pages of Significant Interest
- Writings - always shows latest entries, very important to review for new content!
- Developing in C on the AVR ATmega328P: Frequently Asked Questions (FAQ) Like all FAQ’s, if you have a question, check here first.
- Developing in C on the AVR ATmega328P: Frequently Found Errors (FFE) Similar to an FAQ, describes errors found while creating code, best place to check when you have an error you do not understand.
- Developing in C for the ATmega328P: Example Code Example code for all of the functions, if you have a problem with a function, review the example!
Course Material
Developing in C for the ATmega328P
Beginning tutorial using Labs_10C_Class content to help someone replace the Arduino C++ software framework with a Standard C approach.
A broader-based approach using the AVR_C repository is recommended for a detailed approach to learning C for the AVR-family of microcontrollers.
- Developing in C for the ATmega328P: Getting Started
- Developing in C for the ATmega328P: Setup Introduction
- Developing in C for the ATmega328P: Raspberry Pi and VS Code Setup (Best Method)
- Developing in C for the ATmega328P: Linux Setup (Advanced)
- Developing in C for the ATmega328P: macOS Setup (Advanced)
- Developing in C for the ATmega328P: Windows/WSL Setup (Deprecated)
- Developing in C for the ATmega328P: Windows 10 Setup (Advanced)
- Developing in C for the ATmega328P: Using git
- Developing in C for the ATmega328P: Edit
- Developing in C for the ATmega328P: Build
- Developing in C for the ATmega328P: Upload
- Developing in C for the ATmega328P: AVR_C Library Functions
- Developing in C for the ATmega328P: Using a Serial Monitor
- Developing in C for the ATmega328P: Functions - Serial input/output
- Developing in C for the ATmega328P: Function - analogWrite()
- Developing in C for the ATmega328P: Functions - Serial input/output
- Developing in C for the ATmega328P: Function - digitalWrite()
- Developing in C for the ATmega328P: Function - pinMode()
- Developing in C for the ATmega328P: Function - digitalRead()
- Developing in C for the ATmega328P: Struct - buttons[]
- Developing in C for the ATmega328P: Function - analogRead()
- Developing in C for the ATmega328P: Hints
- Developing in C for the ATmega328P: Mapping Values
- Developing in C for the ATmega328P: Using Data Types and Math
- Developing in C for the ATmega328P: Marking Time and Measuring Time
- Developing in C for the ATmega328P: User Functions
- Developing in C for the ATmega328P: Multi-tasking the Arduino - Part 1
- Developing in C for the ATmega328P: Function - tone()
- Developing in C for the ATmega328P: Using PROGMEM
- Developing in C for the ATmega328P: structures
- Developing in C for the ATmega328P: Code vs. Cost
- Developing in C for the ATmega328P: Pointers
- Developing in C for the ATmega328P: Servos
- Developing in C for the ATmega328P: I/O Ports
- Developing in C for the ATmega328P: Make, Makefile and env.make
- Developing in C for the ATmega328P: Better Serial Input
- Developing in C for the ATmega328P: Using the GNU Linker to Enhance printf()
- Serial Applications for Embedded Development
- Developing in C for the ATmega328P: Using the GNU Linker to Enhance printf()
- Developing in C for the ATmega328P: Better Serial Input
- Developing in C for the ATmega328P: A Second Serial Port
- Developing in C for the ATmega328P: Raspberry Pi and VS Code Setup Part 1
- Developing in C for the ATmega328P: Raspberry Pi and VS Code Setup Part 2
- Developing in C for the ATmega328P: Raspberry Pi and VS Code Setup Part 3
- Developing in C for the ATmega328P: Buffer Overflow
AVR Datasheet Notes
Technical tutorial using specific capabilities of the ATmega328P chip. This content is intended to help somone understand how to use the datasheet to implement a specific function using the ATmega328P.
Programming Examples
Intermediate tutorials focused on using the AVR-gcc library or examples from the library.
- Developing in C for the ATmega328P: Comparison of Languages
- AVR-gcc Note: Simple Project
- Using the Standard C Framework
- Writing Multitasking Programs
- Using Makefiles to Automate Development
Hardware Debugging
Technical tutorials on using Bloom, gdb, debugWIRE, a hardware debugger such as the Microchip SNAP or the one on the ATmega328PB Xplained Mini board to debug programs on the microcontroller.
- Hardware Debug: Using gdb to debug
- Hardware Debug: Setup Bloom and gdb to Debug
- Hardware Debug: Examples of Bloom with gdb to Debug
- Hardware Debug: Hints on Solving Issues Bloom and gdb
- Hardware Debug: Exploring the ATmega328PB Xplained Mini
- Hardware Debug: Command and Configuration Reference for Bloom and gdb
Reference Content on C
Reference books which are important for understanding C
- The C Programming Language Kernighan and Ritchie - available in PDF and paper copy
- Barr Group: Embedded C Coding Standard
- SEI CERT C Coding Standard
- Arduino Resources page
- comp.lang.c FAQ
Comments powered by Talkyard.