cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
nakanish
Observer
Observer
3,272 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
jasonjiang
Newbie
Newbie
3,262 Views
Registered: ‎07-20-2010

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);
}


 

View solution in original post

Tags (1)
0 Kudos
1 Reply
jasonjiang
Newbie
Newbie
3,263 Views
Registered: ‎07-20-2010

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);
}


 

View solution in original post

Tags (1)
0 Kudos