Wellys Dev

  • Home
  • Search/Topics
  • Writings
  • About
  • 2021-11-20
    DEPRECATED: Developing in C for the ATmega328P: Windows Setup Using WSL1

    DEPRECATED: Due to Microsoft’s inability to enable serial ports in WSL 2, attempting to perform embedded development in WSL is futile. I strongly recommend Linux, macOS or Windows, instead.

    Where I setup the Standard C tool chain (avr-gcc) for the ATmega328P on Windows 10 using Windows Subsystem for Linux (WSL1).

    If you are looking to install the AVR toolchain for C using Windows 10 (and not WSL), go here.

    Background

    Windows has two different operating environments, Windows (the Graphical User Interface or GUI) and the command line, otherwise known as the command prompt. The former is the typical method of using Windows and the latter is used for program automation and Windows program development. It is entered by typing cmd in the Windows search bar. It is this type of command line environment which we want to use to develop C software for the Uno. For example, the GCC compiler for C is intended for use in a command line environment, however, the environment is expected to Linux and not Windows command prompt.

  • 2021-11-20
    Developing in C for the ATmega328P: macOS Setup

    Where I setup the Standard C toolchain (avr-gcc) for the ATmega328P on macOS using homebrew.

    Test with the Arduino IDE!

    After performing these steps on multiple machines, I’ve found it best to install and test using the Arduino IDE before going forward with the installation instructions below. This will reduce the errors to something more manageable and having the Arduino IDE is handy for its Serial Monitor as well it provides an easy method to which port the Uno is connected.

  • 2021-11-20
    Developing in C for the ATmega328P: Linux Setup

    Where I setup the Standard C toolchain for the ATmega328P for Linux, with specific emphasis on the Raspberry Pi.

    Test with the Arduino IDE!

    Note: If you have a GUI interface to your Linux PC, by all means, install the Arduino Legacy IDE (1.8.19). In the steps regarding the Raspberry Pi, the interface will be the terminal and can’t use the Arduino IDE GUI. After performing these steps on multiple machines, I’ve found it best to install and test using the Arduino IDE before going forward with the installation instructions below. This will reduce the errors to something more manageable and having the Arduino IDE is handy for its Serial Monitor as well it provides an easy method to which port the Uno is connected.

  • 2021-11-20
    Developing in C for the ATmega328P: Setup Introduction

    Updated: Where I describe the optional steps to setup the Standard C toolchain for the ATmega328P on Windows, Linux, or macOS using a command line-based approach.

    Update

    In my efforts to continue to refine how to develop Standard C code for the AVR family of microcontrollers, I’ve determined using a Raspberry Pi along with VS Code can provide the optimal experience.

    The Raspberry Pi OS is a reliable and steady operating system on which one can build the latest GCC tools for developing code for any microcontrollers in the AVR family. This includes the latest in the DA, Tiny or DD families.

  • 2021-09-27
    Developing in C for the ATmega328: A Simple Project

    Where I use an example project from avr-gcc to better understand how to program the ATmega328.

    Sources

    • Microchip AVR ATmega328 Go to this page for the datasheet, you will need it.
    • Definitive UNO pinout
    • avr-libc Standard AVR C Library
    • avr-libc: simple project The project which this entry will cover.

    Introduction

    In the previous entry, I wrote a C equivilent to the Arduino analogWrite(). The entry demonstrates the fundamental method of getting the ATmega328 to perform, is to program the registers. From here on, we’ll continue to expand on this approach.

  • 2021-09-22
    AVR Datasheet Note: analogWrite()

    Where I take the next step in developing PWM code in C for the ATmega328. This time, I create a new analogWrite() in C.

    Sources

    • Microchip AVR ATmega328 Go to this page for the datasheet, you will need it.
    • Definitive UNO pinout, see below
    • avr-libc Standard AVR C Library
    • Secrets of Arduino PWM Great tutorial as to how to write code for PWM on the ATmega328
    • DIYODE: PWM Classroom Great educational article on PWM and DC Motors
    Arduino Uno Pinout

    Introduction

    In the previous entry, I demonstrated how you could program the ATmega328 to provide a fast PWM signal on pins 5 and 6. In this entry, I’ll take the example a bit further by adjusting for all 6 pins which can provide a PWM signal. (Those marked by a “~” on the Arduino UNO.) I’ll also continue to refine the table which documents how to program the 6 pins.

  • 2021-09-14
    AVR Datasheet Note: PWM

    Where I take the next step in developing code in C for the ATmega328. This time, I review the PWM functionality of the ATmega328.

    Sources

    • Microchip AVR ATmega328 Go to this page for the datasheet, you will need it.
    • Definitive UNO pinout, see below
    • avr-libc Standard AVR C Library
    • Secrets of Arduino PWM Great tutorial as to how to write code for PWM on the ATmega328
    • DIYODE: PWM Classroom Great educational article on PWM and DC Motors
    Arduino Uno Pinout

    Introduction

    Pulse-width modulation (PWM) is a useful technique for controlling DC motor speeds, LED intensity and creating analog waveforms. The idea is to modulate (or change) the width of a digital signal (a pulse) to deliver a varying amount of voltage. The change is called the “duty cycle”, it will range from 0-100%, and the high the number, the greater the voltage delivered. PWM is valuable as it allows you to use less power to keep motors running or make LEDs bright. If the concept remains foreign to you, I recommend you read the noted sources above before going forward.

  • 2021-09-13
    AVR Datasheet Note: Blink

    Where I use a detailed analysis of the ATmega328P datasheet to develop C code using the C toolchain. Yes, another look at the blink program!

    Sources

    • Microchip AVR ATmega328P Go to this page for the datasheet, you will need it.
    • Definitive UNO pinout, see below
    • avr-libc Standard AVR C Library.

    Introduction

    You’ve installed the tool chain, you’ve tested it and added automation. This means you are now ready to begin the process of learning how to program an embedded microcontroller! You might have thought, that was what you were doing with the Arduino. Not quite, you were programming a specific embedded microcontroller board with a specific programming framework.

  • 2021-09-11
    Developing in C for the ATmega328P: Introduction

    Where I begin the process of developing in Standard C (and only C) on the Arduino Uno (also known as the ATmega328P).

    Sources

    • ATmega328P Datasheet
    • Definitive UNO pinout
    • Arduino in C | Freedom Embedded
    • Make: AVR Programming
    • Commentary on Microcontroller Development
    • AVR Dudes Development tool software for AVR family (avrdude and avarice) as well as source to avr-libc.

    Introduction

    This series is designed to help someone who has been using the Arduino framework, however, desires to use only the C Language. It covers adding the toolchain to your system of choice, executing the toolchain on examples and (possibly) advancing the ability to debug using a hardware debugging tool. Or stated more formally:

  • 2021-05-28
    PinTest

    Where I write an Arduino program to test pins on a specific board in order to confirm a Forth HAL for the same board.

    Pin Testing

    When writing software which will control a circuit, it is best to confirm the behavior of circuit using known or familar test software before attempting to write with a new language. For example, I am developing a HAL/Primitive/User layer for the ESP32 using ESPForth. As the board, the Adafruit HUZZAH32 has an Arduino framework already developed for it, it is a good idea to test the board using the Arduino C++ code before testing it with the ESPForth words.

Page 7 of 8
Copyright © 2025 Lief Koepsel
  • Home
  • Search/Topics
  • Writings
  • About