> What’s New ? <

Learning Modules - Blinkies

This page will eventually present a number of STM32F0 Discovery board blinkies for you to work thru. Each one has a descriptive page explaining the operation.

Things You Will Need

A STM32F0 Discovery Board

Don’t forget the tech manuals!

_images/stm32-disco.jpg _images/qfn32-header-pcb-stm32f051-run-mode.jpg

Mecrisp-Stellaris Forth

See https://sourceforge.net/projects/mecrisp/files/ to download the latest version for Cortex-M processors; mecrisp-stellaris-X.x.x.tar.gz, get the one with the most recent date.

Refer to: methods for flashing Mecrisp-Stellaris Forth onto your board or chip.

A Serial Terminal Emulator

A serial terminal emulator running on a PC which provides the Forth REPL user interface. Also needed will be a serial 3.3v to USB dongle

_images/zeptocom-chrome-15feb23.jpg

Or SWDCOM

Advanced Only: Use SWDCOM to access the REPL using the MCU SWD pins connected to a SWD/USB interface like this $5 Chinese one.

_images/swd-usb-interface-dongle.jpg

Or Make your own SWD/USB Interface from a $2 Blue Pill

SVD2DB, a Peripheral Configuration Search Tool

SVD2DB is a search tool for STM32F0xx CMSIS-SVD Register names, *Register Memory Addresses, Register Access Rights, BitWidths, BitOffsets, and description fields*. This assists the createion of programs like blinky-1.fs, and greatly reduces searching thru the Technical Manual for this information.

_images/svd2db-v1-f0xx.jpg

All set up and ready ?? You should now have a terminal window open that looks somewhat like the picture below.

_images/terminal-window.jpg

Plus:

  • a PDF window with the STM32F051 Reference Manual RM0091 open

  • a SVD2DB (readdb) window open

    LETS GO!

Learning Modules

For portable code, a much better approach is to define application APIs in a generic way, like init_system_timer(), and then implement this function in a platform specific way using registers.

blinky-1a.fs

The only module so far.

\ Program Name: blinky-1.fs  for Mecrisp-Stellaris by Matthias Koch
\ This program blinks a green led, it's the simplest of 'blinkies' 
\ Hardware: STM32F0 Discovery board
\ Author:  T.Porter
\ Version 5183fa45 

\ Enable GPIO's A,B,C,D and F in RCC_AHBENR
1 17 lshift
1 18 lshift 
1 19 lshift 
1 20 lshift 
1 22 lshift 
+ + + + $40021014 BIS!

\ Set GPIOC_MODER_MODER9 to general purpose output mode
%01  18 lshift $48000800 bis!		

\ Delay 500000 loops because the MCU is so fast, without it the LED would only appear dimly lit, with no visible flashing.
: delay 500000 0 do loop ;

\ Set GPIOC_BSRR_BS9 to 1  <-- note the BS9, This Sets GPIOC9
: green-led.on   %1 9 lshift $48000818 ! ;	

\ Set GPIOC_BSRR_BR9 to 1  <-- note the BR9, This Resets GPIOC9
: green-led.off  %1 25 lshift $48000818 ! ; 
 
: blink		
do
green-led.on
delay
green-led.off
delay
loop
;	

\ enter "blink" to start the blinky, reset the board to stop it

Download blinky-1a.fs–> Download blinky-1a.fs

Operation of blinky-1a.fs –> blinky-1a Explained