Working Forth Projects

Note

All Projects licensed under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Note

All project code is CMSIS-SVD compliant for easy code reuse.

  • You will need to load memory map words for all registers used. See Svd2forth-v2 for a easy way to generate a memmory mapped file for any of the projects below.

Square Wave Generator

  • Hardware: STM32F0 Discovery Board using a STM32F0xx MCU
  • Clock: 8 Mhz using the stm32f0 target chip internal RC clock as default with Mecrisp-Stellaris
  • Duty Cycle: 50 %
  • Frequency Range: 123 Hz to 350 KHz
  • Waveform: Square wave at 3.0 Volts
  • Output: on pin PB-1
  • Registers required: RCC, GPIOB, TIM14
  • Files required: freq-gen-memmap.txt and freq-gen.txt
  • Upload to your F0 Mecrisp-Stellaris Forth MCU in this order: freq-gen-memmap.txt, freq-gen.txt and you should see a 5000 Hz square wave appear on PB-4
  • Enter “<freq> hz” at the Forth prompt to change the frequency. “<freq>” must be between 123 and 350000 or PB-1 will just go to a High level.

freq-gen-memmap.txt freq-gen.txt

Screenshot:-
Forth> 20000 hz
-> 20000 hz
<- for a output of 20000 Hz (CLOCK = 8MHz, Prescaler = 0) TIM14_ARR is $00000190
<- ok.

100 Microsecond Systick

  • STM32F0 Discovery Board using a STM32F0xx MCU
  • Utilises the 8MHz MCO crystal controlled frequency from the SWD programmer
  • Overclocked to 96 MHz using the crystal derived 8 MHz MCO clock from the SWD programmer.
  • GPIOA_8 may be monitored to confirm the overclock is working. Look for 48MHz (1/2 clock) on this pin.
  • A marker pulse on GPIOB_2 is generated every Systick for external measurement. Period = 100us, Width = 800 nS
  • Flashes the BLUE LED (on GPIOC_8) at a rate of 1 second

100 Microsecond Systick

Overclock to 96 MHz

  • STM32F0 Discovery Board using a STM32F0xx MCU
  • Utilises the 8MHz MCO crystal controlled frequency from the SWD programmer
  • Increases the default Mecrisp-Stellaris speed by 12 times
  • Optional MCO frequency monitor pin on GPIOA-8

Overclock to 96 MHz

48 MHz System Clock

  • STM32F0 Discovery Board using a STM32F0xx MCU
  • Utilises the 8MHz MCO crystal controlled frequency from the SWD programmer
  • Increases the default Mecrisp-Stellaris speed by 6 times to the rated maximum of 48 MHz
  • Optional MCO frequency monitor pin on GPIOA-8

48mhz clock

Delay using the interrupt driven 1 millisecond Systick

  • STM32F0 Discovery Board using a STM32F0xx MCU
  • Default Mecrisp-Stellaris 8Mhz RC system clock
  • Blue LED blinks at one second Interval
  • 1mS marker pulse is available on PB2 for scope fine tuning
  • ‘msdelay’ word provides a accurate time delay via the systick
  • By Terry Porter based on code by kfoltman

msdelay

Interrupt driven 1 millisecond systick

  • STM32F0 Discovery Board using a STM32F0xx MCU
  • Default Mecrisp-Stellaris 8Mhz RC system clock
  • Blue LED blinks at one second Interval
  • 1mS marker pulse is available on PB2 for scope fine tuning
  • ‘delay’ word times a simple DO LOOP with the systick
  • By Terry Porter based on code by kfoltman

Interrupt driven Systick

Analog To digital converter

  • STM32F0 Discovery Board using a STM32F0xx MCU
  • Default Mecrisp-Stellaris 8Mhz RC system clock
  • No DMA or interrupts used
  • Scans all 19 available channels of the ADC: PA0-7, PB0-1, PC0-5, VREF, VBAT and Temperature sensor in DegreesC
  • By Terry Porter

Analog To Digital Converter

Morse code generator

  • STM32F0 Discovery Board using a STM32F0xx MCU
  • Default Mecrisp-Stellaris 8Mhz RC system clock
  • LEDS blink for DASH and DOT’s
  • PA4 drives a piezo loudspeaker to hear the Morse Code
  • By quaak.haak, Terry Porter

Morse code generator