SVD2FORTH-V6 Video

SVD2FORTH-V6 is my latest version and it has a LOT of changes!

Somewhere around V5 a number of possibilities occured to me in almost all areas so almost everything has changed. This is still a work in progress.

Changes

  1. Preprocessor: the Gema preprocessor now supplies all dependencies, including memory mapped constant Words and bitfield Words. These no longer need to be hand coded/pasted into the project source.

  2. Patern Files: made by SVD2FORTH-V6 to suit Gemma

  3. Smarter processing of bitfield templates

I wrote about SVD2FORTH-V6 in a earlier article.

Video

https://sourceforge.net/projects/mecrisp-stellaris-folkdoc/files/svd2forth-v6-2021-06-26_15.47.01.ogg THERE IS NO VIDEO!! I may add it later. Be sure to use this document in conjunction with the video TIMESTAMPS.

This video shows my new SVD2FORTH-V6 uploading a Blinky to a STM32F0 Discovery Board running Mecrisp-Stellaris Forth.

Windows

There are 4 windows, and everything is done in real time.

  1. Top Left: The Forth terminal screen (SWDCOM) which talks interactively to the Discovery Board in real time during development.

  2. Bottom Left: A webcam video of the STM32F0 Discovery Board to show the LEDS blinking.

  3. Top Right: A Xterm from which I run ‘make lib’ or ‘make’ to build the process.

  4. Bottom Right: My Gvim editor where all source is created.

00:00:00

The Discovery Board hosts a default Mecrisp-Stellaris (20KB) but no program is loaded or running at this point. You can see the Blinky program in the editor whaiting to be uploaded.

00:00:10

“Make lib” is entered into the Xterm and you can see fourth source uploading to the terminal screen which ends with the following stats:

---------------------------
Library Upload Speed Stats:
---------------------------
Stats for the last 'make lib' source upload
Number of uploaded Words: 210
Source upload time : 5,38 seconds
Source upload/compile rate: 38,9 Words per second
Hardware: STM32F051 @ 48MHz Sysclock
Upload method: SWD2 <https://github.com/Crest/swdcom>

These show that 210 Words (programs) were uploaded and compiled in 5.38 seconds to the STM32F051 running at 48MHz with no errors. These are my standard development aids while working on a project. Most of them are not needed for the finished product.

00:00:38

Here one of those development aids “the real time register print” which is shown, as it prints the value of the important RCC_CR register.

rcc_cr.
rcc_cr.   $03035283
            P             H H
            L P         C S S H                             H
            L L         S E E S                             S H
            R L         S B R E                             I S
            D O         O Y D O|    HSICAL     |         |  R I
            Y N         N P Y N|7:6:5:4:3:2:1:0| HSITRIM |  D O
           |2|2|       |1|1|1|1|1|1|1|1|1|1| | |4:3:2:1:0|  Y N
~|~|~|~|~|~|5|4|~|~|~|~|9|8|7|6|5|4|3|2|1|0|9|8|7|6|5|4|3|~|1|0
0 0 0 0 0 0 1 1 0 0 0 0 0 0 1 1 0 1 0 1 0 0 1 0 1 0 0 0 0 0 1 1

This shows that the High Speed Internal and External clocks, plus the PLL are enabled and ready, which is how we get a 48MHz clock.

00:00:52

“Make” is entered into the Xterm and the Blinky sourcecode flashes up the terminal screen. The Discovery Board green and blue LEDS begin blinking.

Experienced Forth users may be wondering how this is happening when the source code is clearly incomplete, where are the dependencies ?

Source Code

\ Enable Port-C
RCC_AHBENR_IOPCEN RCC_AHBENR bis!

\ Set PC9 and PC8 as output
OUTPUT GPIOC_MODER_MODER9<< OUTPUT GPIOC_MODER_MODER8<<
                                  +   GPIOC_MODER bis!
\ Create On and Off for Green and Blue user LEDs
: greenon ( -- ) GPIOC_BSRR_BS9! ;
: greenoff ( -- ) GPIOC_BSRR_BR9! ;
: blueon ( -- ) GPIOC_BSRR_BS8! ;
: blueoff ( -- ) GPIOC_BSRR_BR8! ;

\ one second delay
: waitone  ( -- )
  1000 ms.delay
;

\ Turn on Green, off Blue ...
: blinking  ( -- )
begin
   greenon blueoff waitone
   greenoff blueon waitone
again
;

blinking

For instance, where are RCC_AHBENR, GPIOC_MODER_MODER9<<, GPIOC_MODER_MODER8<< declared etc ? They must be in another file loaded earlier right ?

That’s certainly true, they were loaded earlier but not by me or anyone else. A machine did it …

00:01:06

I press ctrl+c and SWDCOM resets the Discovery Board and the leds stop blinking.

00:01:11

The method is revealed when I show the contents of “include.fs” in the editor window. Here are all the dependencies that the Blinky code needed above.

\ ------------------------------------------------------------------------------ \
\ includes.fs
\ preprocessed dependencies from svd2forth-v6-f0disco-blinky
compiletoram
$40021014 constant RCC_AHBENR \ AHB Peripheral Clock enable register  RCC_AHBENR
$48000800 constant GPIOC_MODER \ GPIO port mode register
$48000818 constant GPIOC_BSRR \ GPIO port bit set/reset  register
: GPIOC_BSRR_BR8!  ( -- ) 1 24 lshift GPIOC_BSRR !  ; \ wo, bitWidth:1 bitOffset:24   Port x reset bit y y =  0..15
: GPIOC_BSRR_BR9!  ( -- ) 1 25 lshift GPIOC_BSRR !  ; \ wo, bitWidth:1 bitOffset:25   Port x reset bit y y =  0..15
: GPIOC_BSRR_BS8!  ( -- ) 1 8 lshift GPIOC_BSRR !  ; \ wo, bitWidth:1 bitOffset:8   Port x set bit y y=  0..15
: GPIOC_BSRR_BS9!  ( -- ) 1 9 lshift GPIOC_BSRR !  ; \ wo, bitWidth:1 bitOffset:9   Port x set bit y y=  0..15
: GPIOC_MODER_MODER8<< ( %bb -- x ) 16 lshift  ; \ rw, bitWidth:2 bitOffset:16   Port x configuration bits y =  0..15
: GPIOC_MODER_MODER9<< ( %bb -- x ) 18 lshift  ; \ rw, bitWidth:2 bitOffset:18   Port x configuration bits y =  0..15
: RCC_AHBENR_IOPCEN ( -- x )  1 19 lshift  ; \ rw, bitWidth:1 bitOffset:19   I/O port C clock enable

Who made includes.fs ?

When I entered ‘make’, the Gema preprocessor, searched the Blinky source, used the pattern files to locate the dependencies and saved them in the includes.fs file which was then uploaded before the source. If you look in the terminal window you can see the sequence.

SVD2FORTH-V6, by automatically providing dependencies is a little bit more helpful now and behaving a bit like the C programming language where all these things are normally provided in include and header files. However this is STILL forth, you can still type the entire program in the terminal if you like :)

This completes my quick demo, I hope you have enjoyed it.