cancel
Showing results for 
Search instead for 
Did you mean: 

Gcc optimization problem

User.151
Associate

I have a problem in STM32CubeIDE.

unsigned char readKey (void)
{
	volatile unsigned char keyValue=HAL_GPIO_ReadPin (KEY_GPIO_Port, KEY_Pin);
	if (0 == keyValue)
	{
		printf ("before delay\r\n");
		HAL_Delay (10);
		keyValue=HAL_GPIO_ReadPin (KEY_GPIO_Port, KEY_Pin);
		if (0 == keyValue)
		{
			printf ("after delay\r\n");
			return 1;
		}
	}
	return 0;
}

These codes will be OK in keil. But the STM32CubeIDE will not be able to print characters. My optimization level is -O0.

2 REPLIES 2
Ozone
Lead

This is not Unix/Linux with standardized stdin + stdout channels.

Check the CubeIDE documentation what the printf is supposed to do there. "Semihosting" would ba a keyword.

Or even better, stick with Keil.

Brian TIDAL
ST Employee

Hi,

see AN4989 (STM32 microcontroller debug toolbox) §7 Printf

This is Everything You Always Wanted to Know About Printf* (*But Were Afraid to Ask)

Rgds

BT

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.