Reputation: 96
I'm starting to use CubeIDE to program a NUCLEO-F401RE board (with sensors attached) and in one of my projects I had to get the voltage of the board and print it somewhere on my laptop (connected to the board via usb cable).
I got this to work using HAL_UART_Transmit function to send the string and PuTTY, on my laptop, to receive and print the string.
Now, I noticed that there is a Console integrated in the IDE where the IDE automatically prints control information, compilation errors and such and I'd like to print the voltage (possibly using printf since I'm programming in C) here rather than using PuTTY, but it doesn't seem so straightforward (as in many other IDEs that I've used) from what I've read on the internet, for instance, here.
I get that here we have two different computers talking to each other, so printing using printf is not as easy as in other situations where code is written, compiled and executed all on the same computer.
My question is:
why isn't there a "console tab" in the IDE where the result of the printf, generated on the board, is displayed? And if there is, how to set it up? Is it simply some settings configuration in the project properties or do I have to modify the low level I/O C functions as stated in the discussion linked above?
Thank you.
Upvotes: 1
Views: 12652
Reputation: 23
https://www.youtube.com/watch?v=WLqUImiV5Gs
this video might help and I will attach the code for you as well
//Paste this code in main.c file
int _write(int file, char *ptr, int len)
{
int DataIdx;
for (DataIdx = 0; DataIdx < len; DataIdx++)
{
ITM_SendChar(*ptr++);
}
return len;
}
//Paste this code in syscalls.c
#define DEMCR *((volatile uint32_t*) 0xE000EDFCU)
#define ITM_STIMULUS_PORT0 *((volatile uint32_t*) 0xE0000000)
#define ITM_TRACE_EN *((volatile uint32_t*) 0xE0000E00)
void ITM_SendChar(uint8_t ch)
{
DEMCR |=(1<<24);
ITM_TRACE_EN |= (1<<0);
while(!(ITM_STIMULUS_PORT0 & 1));
ITM_STIMULUS_PORT0 = ch;
}
Upvotes: 0
Reputation: 46
Create a new Command Shell Console.
Configure the new Console just as you did with PuTTY.
Upvotes: 2