cancel
Showing results for 
Search instead for 
Did you mean: 

STM8S003F3P6 Help required.

PReed.1
Associate II

i am currently working on a temperature project which many may well have heard of. the W1209 temperature controller. and i have found everything i need to implement this circuit into my existing project with other features. the code is open for anyone to have and so is the circuit. only from the files i downloaded i need to compile them so i get a hex file that i can the program the chip with. i have some knowledge with arduino and pic from a long time ago, but am struggling to understand how to do this.

i have bought the ST Link v2 dongle for programming and not sure which software to best use. if there is anyone who can help and compile the program so i can have the file i need to just send to the chip i would be so grateful.

11 REPLIES 11
Philipp Krause
Senior II

Find out which compiler your code was written for (IAR and SDCC are quite standard-complinat making it easy to compile code written for one with the other, slightly harder for code originally written for Cosmic or Raisonance).

Once compiled, you write the program onto the device (e.g. you use SDCC to compile C code into an Intel hex .ihx file, then use stm8flash to program the device via the ST-Link/v2).

You mentioned the code is "open". You could post a link to make it easier for us to help you.

PReed.1
Associate II

No problem.

https://github.com/mister-grumbler/w1209-firmware

from here i got the full circuit diagram and program. but i just need the means to have the .hex file that i can load to the chip as the circuit will be done on a different board with other components and buttons in a better place for my project.

Thanks

Looking at the Makefile on Github, the code was written for SDCC.

Which OS do you use? For Debian or Ubuntu, the build procedure from the FAQ (https://github.com/mister-grumbler/w1209-firmware/wiki/FAQ) is probably the easiest. For other Unices, and macOS it will be similar (i.e. install SDCC, then use "make" to build the .ihx file (For Intel hex, both .ihx and .hex are used, this Makefile uses .ihx).

PReed.1
Associate II

you are loosing me there. i use windows?? if thats what your asking?

i have found sdcc small device c compiler. so i am assuming if i install that then the files from github can be used and compiled so i can get a hex file to then program?

am i right in saying that?

Philipp Krause
Senior II

Yes, I was asking about the OS.

A little background:

Source code, written in C (usually .c files, which in turn include some .h files) is usually compiled into object files first (.rel files here). Then the object files are linked together to form a binary (.ihx file here).

So programmers don't have to invoke the compiler for each .c file and then the linker, there are tools to automate this. The most common is a Makefile, executed by the program make. The Makefile contains rules on how to invoke compiler and linker with which options. The GitHub repo contains such as Makefile: https://github.com/mister-grumbler/w1209-firmware/blob/master/Makefile

make is available on most OSes,such as various GNU/Linux distributions. While make is also available for Windows, it is probably a little bit more tricky to use there.

No matter if you decide to use make, or some alternative, or to just compile each source file manually, you'll need the Small Device C Compiler (SDCC, which contains the compiler and linker).

PReed.1
Associate II

sort of thanks... lol.

i have never used linux. is there some videos i can watch to understand the process better. i have used adruino ide and can sort of follow that, but this may be way past what i can do. would there be anyone who would beable to put the file together so i have the hex file that i can just use the STLink and program?

or is there anything to help me start from scratch and learn the process?

I just did it on my Debin GNU/Linux system using these three lines:

git clone https://github.com/mister-grumbler/w1209-firmware.git

cd w1209-firmware

make

Result is at http://colecovision.eu/stuff/thermostat.ihx (I haven't tested that file in any way).

For getting started, I wrote some simple tutorials for various STM8 boards a while ago (written for GNU/Linux, but shouldn't be much different on Windows):

http://colecovision.eu/stm8/

Many developers, especially on Windows prefer to use an IDE instead of manually editing Makefiles. One IDE that supports SDCC (and an installed SDCC is detected when installing the IDE) is Code::Blocks.

> git clone https://github.com/mister-grumbler/w1209-firmware.git

> cd w1209-firmware

> make

I suppose under Windows that would work with Cygwin and the proper packages as well.

Never tried, since I prefer/have native Linux.

i am guessing that the file .ihx is the hex file that i can use with the stlink v2 dongle? if so you are a star. Thanks.

if i wanted to learn linux and all that? do i need a seperate computer setup with that os on? or is it something that would run inside windows?

or would a raspberry pi work? i have heard they work using linux?