UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Visitor nakanish
Visitor
2,989 Views
Registered: ‎10-01-2008

sprintf causes code to hang during simulation

Jump to solution

When I try using the sprintf() function in my code the processor doesn't get past this command.  Here's the command I'm using...

 

while (format[percent_search] && arg_counter < MAX_ARGS)
  {
    if (special_character)
    {
      special_character = FALSE;
    }
    else
    {
      switch (format[percent_search])
      {
        case '%':
          args[arg_counter++] = va_arg(arg_list, uint_32);
          break;

        case '\\':
          special_character = TRUE;
          break;
      };
    }  /* if (special_character) */
   
    percent_search++;
  }  /* while */

  va_end(arg_list);

  /* Create final string to send  */
  sprintf(out_str, format, args[0],
                           args[1],
                           args[2],
                           args[3],
                           args[4],
                           args[5],
                           args[6],
                           args[7],
                           args[8],
                           args[9],
                           args[10]);

 

 

Has anyone out there had any problem with the sprintf() function?  Any ideas on what would cause this problem?

0 Kudos
1 Solution

Accepted Solutions
Highlighted
Newbie jasonjiang
Newbie
2,980 Views
Registered: ‎07-20-2010

Re: sprintf causes code to hang during simulation

Jump to solution

I got the same issue.

 

You have to use Microblaze library, my_sprintf(), defined in xil_printf.c like below:


/*-------------------------------------------------------------------------*/

//
// This is the start of the file for other *printf functions
// that are used in the embedded system.  For some reason,
// the standard printf functions provided in the Xilinx
// library do not seem to work.
//

int my_sprintf(char *buff, char *fmt, ... )
{
    va_list ap;
    int     length;

    va_start(ap, fmt);
    length = xil_vsprintf(buff, fmt, ap);
    va_end(ap);

    return (length);
}


 

Tags (1)
0 Kudos
1 Reply
Highlighted
Newbie jasonjiang
Newbie
2,981 Views
Registered: ‎07-20-2010

Re: sprintf causes code to hang during simulation

Jump to solution

I got the same issue.

 

You have to use Microblaze library, my_sprintf(), defined in xil_printf.c like below:


/*-------------------------------------------------------------------------*/

//
// This is the start of the file for other *printf functions
// that are used in the embedded system.  For some reason,
// the standard printf functions provided in the Xilinx
// library do not seem to work.
//

int my_sprintf(char *buff, char *fmt, ... )
{
    va_list ap;
    int     length;

    va_start(ap, fmt);
    length = xil_vsprintf(buff, fmt, ap);
    va_end(ap);

    return (length);
}


 

Tags (1)
0 Kudos