sprintf() format specifiers don’t seem to be working… why not?
sprintf() format specifiers don’t seem to be working… why not?
Hi,
I’m having an issue formatting strings to be output via the serial port R_UART0_Send() function…
Constant strings don’t seem to have an issue, but if I try to insert data using a format specifier, the resulting string is corrupted and doesn’t print properly.
e.g.
strMsg = sprintf(“Test string….\r\n”);
R_UART0_Send( strMsg, strlen(strMsg) ); This works…
//—————————————————————//
strMsg = sprintf(“Test string….0x%02X\r\n”, hexVal);
R_UART0_Send( strMsg, strlen(strMsg) ); This doesn’t work…
//—————————————————————//
It doesn’t seem to matter whether the variable strMsg is defined as a uint8_t * or as a char *.
The thing is, it worked initially (As I’ve built up the code it seems to have gotten worse)…
Any hints or suggestions would be appreciated…
Steve
Hi, I am facing the same Problem. I can see that the IO pins are working in simulator but not the UART output.
void main(void)
{
R_MAIN_UserInit();
/* Start user code. Do not edit comment generated here */
R_UART0_Start();
P1 = 0x10;
int i =0;
double j=0,x=0;
while (1U)
{
if(i == 0)
{
P1 = 0xFF;
i=1;
}
else
{
P1 = 0x00;
i=0;
}
R_UART0_Send(“Hello\r\n”,8);
filler();
}
/* End user code. Do not edit comment generated here */
}
Hello Steve,
Please provide us with more detailed information, including a sample project if possible. If not, we would at least need to know the following details:
– CPU
– library type(newlib, optlib) and if prebuilt/project-built
– actual observed output
Thank you.
–
Best Regards,
Grigore Dobra,
The GNU Tools Team