This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

uVision printf debugging using STM32F7xx

Hello,

I am having trouble finding a good source to help me set up printf debugging on my project. I am currently using the STM32F7xx series board with uVision and MXCUBE to initialize the project. Most of the sources I find are fairly old and do not seem to work. Is there an updated page I could look at to help me set it up? Thank you for your assistance!

Parents
  • Pretty sure the usual fputc() code works, you might need to enable access to the ITM registers.

    community.st.com/.../147118-stm32f769i-disco-printf-using-itmswo

    volatile uint32_t *ITM_LAR = (volatile uint32_t *)0xE0000FB0; // ITM->LAR
    *ITM_LAR = 0xC5ACCE55; // Enable Access
    
    //****************************************************************************
    // Hosting of stdio functionality through SWV - Serial Wire Viewer
    //****************************************************************************
    
    #include <rt_misc.h>
    
    #pragma import(__use_no_semihosting_swi)
    
    struct __FILE { int handle; /* Add whatever you need here */ };
    FILE __stdout;
    FILE __stdin;
    
    int fputc(int ch, FILE *f)
    {
      ITM_SendChar(ch);
    
      return(ch);
    }
    
    int fgetc(FILE *f)
    {
      char ch;
    
      ch = '?';
    
      return((int)ch);
    }
    
    int ferror(FILE *f)
    {
      /* Your implementation of ferror */
      return EOF;
    }
    
    void _ttywrch(int ch)
    {
      ITM_SendChar(ch);
    }
    
    void _sys_exit(int return_code)
    {
    label:  goto label;  /* endless loop */
    }
    
    //****************************************************************************
    

Reply
  • Pretty sure the usual fputc() code works, you might need to enable access to the ITM registers.

    community.st.com/.../147118-stm32f769i-disco-printf-using-itmswo

    volatile uint32_t *ITM_LAR = (volatile uint32_t *)0xE0000FB0; // ITM->LAR
    *ITM_LAR = 0xC5ACCE55; // Enable Access
    
    //****************************************************************************
    // Hosting of stdio functionality through SWV - Serial Wire Viewer
    //****************************************************************************
    
    #include <rt_misc.h>
    
    #pragma import(__use_no_semihosting_swi)
    
    struct __FILE { int handle; /* Add whatever you need here */ };
    FILE __stdout;
    FILE __stdin;
    
    int fputc(int ch, FILE *f)
    {
      ITM_SendChar(ch);
    
      return(ch);
    }
    
    int fgetc(FILE *f)
    {
      char ch;
    
      ch = '?';
    
      return((int)ch);
    }
    
    int ferror(FILE *f)
    {
      /* Your implementation of ferror */
      return EOF;
    }
    
    void _ttywrch(int ch)
    {
      ITM_SendChar(ch);
    }
    
    void _sys_exit(int return_code)
    {
    label:  goto label;  /* endless loop */
    }
    
    //****************************************************************************
    

Children
No data