Wellys Dev

  • Home
  • Search/Topics
  • Writings
  • About
  • 2024-03-12
    FlashForth: Hardware Abstract Layer (HAL)

    UPDATED: This page contains a both a Forth hardware abstraction level (HAL) much like the m328def.inc file for AVR programming in C and an example of debouncing buttons.

    New Words

    This HAL provides the words:

    I/O Words

    The Arduino pins are defined by bit port so one can use the following commands using the Arduino pin number. This is true for pins D0-D13.

    high    ( bit port -- )     set a Arduino pin high
    low     ( bit port -- )     set a Arduino pin low
    toggle  ( bit port -- )     toggle output value on an Arduino pin
    output  ( bit port -- )     set Arduino pin as output
    input   ( bit port -- )     set a Arduino pin as input
    pullup  ( bit port -- )     set Arduino pin as input_pullup
    read    ( bit port -- f )   read a Arduino pin, returns bit value
    

    For example:

  • 2024-03-12
    FlashForth: Datasheets

    Why the microcontroller datasheet is so important to programming in Forth.

    The Datasheet

    The ATmega328P datasheet is critical to understanding how to program the 328P. Exploring it with Forth is the joy of Forth as Forth allows you to interactively test commands, ports, timers, ADC’s etc of the 328P. And once you are convinced you have the correct set of commands to make what you want to happen, you can codify it into a word that becomes part of the vocabulary of Forth.

  • 2024-03-11
    FlashForth: Understanding the ATmega328P PWM

    Where I use Forth to develop a better understanding of the ATmega328P PWM capabilities. Revised from original post on April 17, 2021

    Sources

    • Flashforth Example on Github

    Introduction

    Pulse Width Modulation (PWM) is a technique used to control analog circuits using digital signals. It is the capability to change either the frequency or duty cycle of a digital signal. The former is the number of times the signal switches from low to high in a given period of time and the latter, is how long it is either high or low.

  • 2024-03-11
    Flashforth: Working with the Uno

    Where I describe how to use Forth with an Arduino Uno and make it easier to program the Uno in Forth.

    Introduction

    The Arduino Uno benefits from an incredible software framework. Between the programs already developed by the Arduino organization, and the hundreds of libraries which were created by others, you can find a program which does what you need. This makes it extremely easy to hit the ground running with a project. FlashForth isn’t like this.

  • 2024-03-10
    FlashForth: blink

    Where I demonstrate your first embedded application, much like the C Language “Hello, World” program, blink.

    A simple program, Blink

    To begin to understand how to program in Forth, I’ll iterate over several versions of blink.

    Light the LED

    First, let’s interactively light the built-in LED. On an Uno, we know it is pin 13, which corresponds to Port B, bit 5 on our microcontroller, the ATmega328P.

    This is lesson one, all references in Forth, are references to the ATmega328P, which is the microcontroller on the Uno, and not the pins on the Uno. This is why the data sheet for the ATmega328P is so important. I’ll call out the specific references as we go, however, the more you use FlashForth, the more you will come to read and understand the ATmega328P datasheet. As you begin to write more Forth programs, you will be able to create the words necessary to reference the Uno, just as you did with the Arduino framework.

  • 2024-03-09
    FlashForth: Simple Setup

    UPDATED: Where I describe how to use FlashForth, a phenomenal version of Forth for the ATmega328P to learn how to use Forth in an embedded system.

    Notes for Video

    This video demonstrates the ease of loading FlashForth on to an Arduino Uno, and replacing it with Optiboot, when you wish to use the Arduino software framework, again.

  • 2024-03-06
    Developing in C for the ATmega328P: Buffer Overflow

    Where I use examples from “The C Programming Language”, Kernighan & Ritchie, to demonstrate string copies, using pointers and how to check for buffer overflows.

    Introduction

    I find it very helpful to periodically review/read “The C Programming Language”, Kernighan and Ritchie (K&R). In this past review, I ran across some examples provided on pages 105-6 (Second Edition) as to using pointers to copy strings. There were 4 examples provided, with the last commented as “the idiom should be mastered”, which is an implication of “this is a programming best practice”. Perhaps, for the code in question is quite simple and extremely powerful, that said, it leads to the issue of buffer overflows, for which I provide a mechanism to resolve.

  • 2024-03-01
    Arduino: Reloading Bootloaders on the Uno and the 32U4

    Where I demonstrate how to reload Optiboot on an ATmega328P (Arduino Uno) and reload the Catarina bootloader on to an ItsyBitsy 32U4 board as well.

    Introduction

    Sometimes a board’s bootloader can become corrupted or you have consciously overwritten the bootloader (See Forth on this site), and you want to reload it. This page demonstrates how to do this with the ATmega328P (Uno) and board with the AVR 32U4 (Adafruit ItsyBitsy 32U4). It also discusses the different bootloaders available for the 32U4.

  • 2024-02-29
    RP2040 MicroPython: Making a Web Server with WebSockets

    Where I expand on creating a web server application on a Pi Pico W by incorporating web sockets.

    Repository

    • MicroPython Webserver on Pico W

    Introduction

    In the first part of this entry, I introduced the ability to develop an HTTP-based web server using solely HTML to control the Pi Pico pins. I focused on HTTP protocol as you can write everything in the relatively simple language, HTML and it works. I used checkbox or radio button inputs to a form to control pins on the Pico. This is a far more simple approach than using JavaScript. It does introduce some significant delays as each form submission must make a complete round trip (i.e. a page reload).

  • 2023

  • 2023-10-02
    Serial Applications for Embedded Development

    Where I discuss various serial monitor applications and why I believe CoolTerm is the best one.

    Introduction

    The serial port is an invaluable, if not mandatory tool, for developing programs in embedded computing. Given the popularity of software development for embedded computers, one would think there would be a clear answer or solution. For several years, I wasn’t able to determine the best solution. However, after more work on my part to understand a specific solution, I can conclusively say use this multiplatform, free solution: CoolTerm

Page 2 of 15
Copyright © 2025 Lief Koepsel
  • Home
  • Search/Topics
  • Writings
  • About