Close

Quickly Adapt Project to stm8ef-modular-build

A project log for stm8-easymon

Use 7 segment displays to monitor numbers of any kind

andrew-clappAndrew Clapp 04/18/2020 at 17:431 Comment

I have been able to quickly apply Thomas's new modular approach to my project.  Thank you!  I grabbed a zip file of the stm8ef-modular-build repo and extracted it on my linux box. I have sdcc and supporting software installed there.  First I edited the board.fs and put in a little cusomization for what I needed.  This file contains the forth code you will be running at the end of your build, after the target is flashed with your new image.  If you write things to NVM here and then COLD or WIPE and start it, the newly programmed micro will now be your own custom embedded device.  By default it will display an analog input on the LEDs as a number from 0 to 1023, which you can scale how you like in the show function, for example:

4 ADC! ADC@  1000 1023 */ . 

This would result in scaling the full range of the input (a voltage from 0-3.3V or from 0-5V depending on your supply, use a regulated supply) to a number between 0 and 1000.  You could scale up from 1023 as well.

If you're building for a different chip, edit the target.inc to reflect the correct memory layout.  I basically changed all the STM8S003F3 to STM8S103F3 (which is  really just this one line for my chip).  This is probably a bit pedantic and may not be necessary.

        EEPROMEND =     0x427F  ; STM8S103F3: 640 bytes EEPROM

 Pay attention to boardcore.inc when you assemble your project for pin numbers and GPIO settings.  The file globconf.inc controls some of the features you're going to use or not use.  You can turn things on and off simply here.  If you don't want a serial console, say you need to use those pins for something else, you can turn of the UART that is on those pins.

        HAS_TXUART       = 0    ; No UART TXD, word TX!
        HAS_RXUART       = 0   ; No UART RXD, word ?RX

There is a README.md file in the DEMO directory, read that in addition to the top level README for all this info and more.  When you're done with your edits you type make, and if you've got all your ducks in a row, it builds the image, flashes it onto your device (that you have connected with your STLINKV2).  Say you have another terminal open, maybe with e4thcom running in it, and you've got a usb-ttl converter connected to the serial console pins on your device as well, you can talk directly to the forth instance running your newly coded environment.

Now why would you even want do this?  The way I had to go about this before was to clone a whole board, like the W1209-CA, directory in the stm8ef repo, modify all the .fs and .inc files, and the top level Makefile to get it to work.  This was a great way to learn it, but using the modular repo is so much easier and faster.

Discussions

Thomas wrote 04/18/2020 at 18:36 point

It's good to see that the new approach for building the STM8 eForth core together with application code works. I think that this approach is in the spirit of C.H. Ting's "Firmware Engineering Workshop" ( http://forth.org/library/eforth_SOC/eforth_SOC_source/eForth2/workshop.ZIP ).
It would be interesting to test if mix-and-merge with SDCC also works this way. Using Forth as an interactive shell for C code has long been a path I'd like to explore.

  Are you sure? yes | no