cancel
Showing results for 
Search instead for 
Did you mean: 

nucleo-L476 / RealTerm / printf not working??

SWenn.1
Senior III

Hello All...

I am trying to send data to realterm using printf....I used cubemx to set up baud rate, etc. and have called MX_USART2_UART_Init. RealTerm is pointing to the correct serial port with the correct baud rate....A breakpoint validates the data is all good. I have included stdio.h. Can someone tell me why I am seeing nothing happen on RealTerm....Also I have tried creating a console in STMCubeIDE and also see nothing happen?? I overwrote the weak _write function (see below)

Thanks

				  for (uint8_t current = 0; current < NUMBER_MSMNTS; current++){
					  printf("CYCLE %d CURRENT %0.1f mA", ((readCycle > 0) ? readCycle : 3), DAC_C[current]);
					  printf("Vbias %0.2f", SensorDataPerCyclePublish.Vbias[current]);
					  printf("SiPM %0.2f", SensorDataPerCyclePublish.SiPMCurrent[current]);
					  printf("LED1 %0.2f", SensorDataPerCyclePublish.LED1Current[current]);
					  printf("LED2 %0.2f", SensorDataPerCyclePublish.LED2Current[current]);
					  printf("WaterT %0.2f", SensorDataPerCyclePublish.w_temp[current]);
					  printf("BoardT %0.2f", SensorDataPerCyclePublish.bd_temp[current]);
				  }
 
 
int _write(int file, char *ptr, int len)
{
	HAL_UART_Transmit(&huart2, (uint8_t *)ptr, len, 50 );
	return len;
}

1 ACCEPTED SOLUTION

Accepted Solutions
KnarfB
Principal III

stdout (what you redirect) is normally line buffered. So nothing shows up until you send a "\n" or maybe some "\r\n" depending on your terminal settings.

Keep also in mind, that floating point output will not work unless you enable it in the project settings (STM32CubeIDE) or set appropriate linker options explicitely.

hth

KnarfB

View solution in original post

3 REPLIES 3
KnarfB
Principal III

stdout (what you redirect) is normally line buffered. So nothing shows up until you send a "\n" or maybe some "\r\n" depending on your terminal settings.

Keep also in mind, that floating point output will not work unless you enable it in the project settings (STM32CubeIDE) or set appropriate linker options explicitely.

hth

KnarfB

SWenn.1
Senior III

Did what you suggested... Still not working??? I notice when I break on a printf and try to step INTO the code steps OVER?? wierd.....

0693W00000YA5bhQAD.png

				  for (uint8_t current = 0; current < NUMBER_MSMNTS; current++){
					  printf("CYCLE %d CURRENT %0.1f mA/n/r", ((readCycle > 0) ? readCycle : 3), DAC_C[current]);
					  printf("Vbias %0.2f/n/r", SensorDataPerCyclePublish.Vbias[current]);
					  printf("SiPM %0.2f/n/r", SensorDataPerCyclePublish.SiPMCurrent[current]);
					  printf("LED1 %0.2f/n/r", SensorDataPerCyclePublish.LED1Current[current]);
					  printf("LED2 %0.2f/n/r", SensorDataPerCyclePublish.LED2Current[current]);
					  printf("WaterT %0.2f/n/r", SensorDataPerCyclePublish.w_temp[current]);
					  printf("BoardT %0.2f/n/r", SensorDataPerCyclePublish.bd_temp[current]);
				  }

SWenn.1
Senior III

Solved..... \r\n NOT /r/n