cancel
Showing results for 
Search instead for 
Did you mean: 

Why doesn't "While" work after adding "-u_printf_float"?

Min-Kyoung Kim
Associate III

I tried to use "sprintf" printing float value.

So I added "-u_printf_float" on the Miscellaneous->Linker flags.

(-specs=nosys.specs -specs=nano.specs -u_printf_float) <- like this

After that, my code doesn't run "while".

Did I use the wrong way?

++ Using stm32L4

++ Tool Chain : Ac6 STM32 MCU GCC

++ Code

while{
 sprintf((char*)debugmsgbuf, "gx : %.3f   gy : %.3f   gz : %.3f   ax : %.3f   ay : %.3f   az : %.3f\r\n",gx, gy, gz, ax, ay, az);
 
 create_debugmsgNull((char*)debugmsgbuf);
}
 
 
void create_debugmsgNull(char* msg)
{
	uint32_t i, j;
	char* ptr;
 
	i = 0;
	ptr = msg;
	j = debugindexWrite;
	while(*ptr != '\0')    debugmsg[j][i++] = *ptr++;
 
	debugmsglength[j] = i;
	j++;
	if(j >= DEBUGMSG_CUELENGTH)  j = 0;
	debugindexWrite = j;
}

4 REPLIES 4
Ozone
Lead

There is no code below.

Information about the MCU and the used toolchain would be helpful, too.

Perhaps a stack overflow.

Thank you for the reply.

I edited my post.

Thank you

Syntax of while looks wrong. So what happens when executing? Ends up in Hard Fault? FPU enabled?​

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

i tried to check what kind of fault occurred.

But i can't find any fault.

I check like this below. (all faults check done)

void HardFault_Handler(void)
{
  /* USER CODE BEGIN HardFault_IRQn 0 */
	USART1->TDR = 'H';
  /* USER CODE END HardFault_IRQn 0 */
  while (1)
  {
    /* USER CODE BEGIN W1_HardFault_IRQn 0 */
    /* USER CODE END W1_HardFault_IRQn 0 */
  }
}

When I erase "-u_printf_float" on Linker flags, It works!

But I can't use float values..