How to use Printf with STM32 Microcontroller- Serial Wire Viewer (SWV)

Поделиться
HTML-код
  • Опубликовано: 2 окт 2024

Комментарии • 29

  • @giupeppe6380
    @giupeppe6380 Год назад +25

    2:52 you forgot to add it in the description

  • @hligfl
    @hligfl Год назад +27

    yw
    #define ITM_TRACE_EN *((volatile uint32_t*) 0xE00000E00)
    #define DEMCR *((volatile uint32_t*) 0xE000EDFCU)
    #define ITM_STIMULUS_PORT0 *((volatile uint32_t*) 0xE00000000)
    /* Debug function for printf used in __write() */
    void ITM_SendChar(uint8_t ch)
    {
    // Enable TRCENA
    DEMCR |= (1

  • @PerOveHusy
    @PerOveHusy 3 месяца назад +1

    The constants used both in the video and in the comments below are erroneous. Gave no output.
    I removed the extra U (??) and made all 4 bytes long (not 4.5)
    #define ITM_TRACE_EN *((volatile uint32_t*) 0xE00000E00)
    #define DEMCR *((volatile uint32_t*) 0xE000EDFCU)
    #define ITM_STIMULUS_PORT0 *((volatile uint32_t*) 0xE00000000)

  • @industrialautomation1992
    @industrialautomation1992 8 месяцев назад +2

    Did the same way but output is not came
    In serial monitor no output

  • @micha68v
    @micha68v 9 месяцев назад +2

    Hi!
    I didnt get any output. Did exactly like showed. STM stucks in while(!(ITM_STIMULUS_PORT0 & 1));
    Ideas?

    • @micha68v
      @micha68v 9 месяцев назад +1

      Same Board, Nucleo F446RE

    • @lunchbreak1040
      @lunchbreak1040 4 месяца назад +1

      same. Have you found the answer?

    • @gcom2286
      @gcom2286 3 месяца назад

      above printf try to define count as it is not defined here
      int count=0;
      printf("the counter value:%d
      ",count);
      count++;
      fflush(stdout);
      HAL_Delay(1000);

  • @adilmubashirchaudhry4115
    @adilmubashirchaudhry4115 11 месяцев назад +1

    Hi! Great tutorial and it does work on the STM32 Nucleo board however I have the STM32f411 Blackpill board which needs to be connected to an external ST-Link v2 debugger. This doesnt print on that. From what I looked into the datasheets the memory addresses for the registers used in code that we added in the syscall is the same. Any suggestions on what to do?

    • @BINARYUPDATES
      @BINARYUPDATES  11 месяцев назад +1

      Hi Adil, thank you. You're right in case of STM32 Blackpill board we don't have built-in STLink programmer and debugger support. So need you need external STM32 programmer and debugger. I want you to check for SWO Pin where it is connected in case of blackpill between STLinkV2. Because the SWV data transmission uses SWO pin for sending debug messages. And if its not soldered then it may not work. I'm not sure as I still have to work on blackpill I've ordered some in future I'll make videos on this topics. Good luck and best wishes!

  • @Llammars
    @Llammars 8 месяцев назад

    Thanks for the guide! I've been having trouble getting this to work though. I'm hoping you might be able to help. I've been trying to get this setup on the b-g431-b-esc1 discovery board, which uses STM32G431CB. At this moment nothing is printing, but I have noticed while debugging that I get stuck in the ITM_SendChar() function - specifically in the while loop - while(!ITM_STIMULUS_PORT0 & 1). I'm too new to C to make sense of what's happening. Any ideas? Thanks!

    • @VietDuc7
      @VietDuc7 7 месяцев назад +1

      You may have a mistake somewhere. Please copy exactly this code:
      //Debug Exception and Monitor Control Register base address
      #define DEMCR *((volatile uint32_t*) 0xE000EDFCU )
      /* ITM register addresses */
      #define ITM_STIMULUS_PORT0 *((volatile uint32_t*) 0xE0000000 )
      #define ITM_TRACE_EN *((volatile uint32_t*) 0xE0000E00 )
      void ITM_SendChar(uint8_t ch)
      {
      //Enable TRCENA
      DEMCR |= ( 1

    • @BINARYUPDATES
      @BINARYUPDATES  7 месяцев назад

      Please confirm if you have properly added the piece of code in syscall.c file. Also, make sure in debugger setting under Serial Wire Viewer section turn on Enable check box. Once you have done this then configure SVW console settings. I hope this may help. Best wishes!

  • @oieieio741
    @oieieio741 Год назад

    I found this very helpful, quickly got me using and understanding stm32 swv. Thank you very much.

    • @BINARYUPDATES
      @BINARYUPDATES  11 месяцев назад

      Hi Oieieio, Glad it helped! thank you!

  • @nitingaikwad5963
    @nitingaikwad5963 Год назад

    not working.

    • @BINARYUPDATES
      @BINARYUPDATES  Год назад

      Hi Nitin, let us know more details on problem you're facing. More details you share better we can help. Best wishes!

  • @hligfl
    @hligfl Год назад

    The man za genius!