Skip to main content
Visitor II
April 3, 2020
Solved

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

  • April 3, 2020
  • 2 replies
  • 2642 views

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

    This topic has been closed for replies.
    Best answer by Philipp Krause

    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).

    2 replies

    Visitor II
    April 6, 2020

    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.

    Visitor II
    April 6, 2020

    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).

    MT.2Author
    Visitor II
    April 8, 2020

    Hi Philipp,

    Thanks for your reply!!!!

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

    Thanks a lot!!!!