cancel
Showing results for 
Search instead for 
Did you mean: 

Is it possible to print the value of variables in STM8s Discovery?

MT.2
Associate II

Hi there!

I am new to STM8s Discovery, could someone suggests me how to print the values of variables in the program? it is more convenient if i can do this but I have no idea how to make it. Thank you very much !

Morris

1 ACCEPTED SOLUTION

Accepted Solutions
Philipp Krause
Senior II

Looking at your question again, maybe you didn't mean on-target debugging, but just plain old output from your program. If you want to do that: Set up an UART for serial output, provide a putchar protoype that uses it, then just use printf() like you would on any other C implementation.

For an example, see e.g. http://www.colecovision.eu/stm8/STM8S-DISCOVERY%20Serial.shtml (the example uses SDCC, but should work without changes for IAR, too, and only require minor changes for Cosmic and Raisonance).

View solution in original post

3 REPLIES 3
Philipp Krause
Senior II

The STM8S supports on-target debugging, so this should just work. AFAIK it is supported by all the usual development environments, be it STVD, or one from IAR, Cosmic or Raisonance.

If you use SDCC, you would do it by compile with --debug --out-fmt-elf to generate ELF/DWARF output that can then be used with OpenOCD and GDB for on-target debugging.

Philipp Krause
Senior II

Looking at your question again, maybe you didn't mean on-target debugging, but just plain old output from your program. If you want to do that: Set up an UART for serial output, provide a putchar protoype that uses it, then just use printf() like you would on any other C implementation.

For an example, see e.g. http://www.colecovision.eu/stm8/STM8S-DISCOVERY%20Serial.shtml (the example uses SDCC, but should work without changes for IAR, too, and only require minor changes for Cosmic and Raisonance).

Hi Philipp,

Thanks for your reply!!!!

I have tried your suggestion and i am able to use printf() now!!!!!

Thanks a lot!!!!