Skip to main content
User.151
Visitor II
July 23, 2019
Question

Gcc optimization problem

  • July 23, 2019
  • 2 replies
  • 795 views

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.

This topic has been closed for replies.

2 replies

Ozone
Principal
July 23, 2019

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
Technical Moderator
July 23, 2019

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.