2024-10-15 04:27 AM
Hi,
With Keil uVision I could type to a console and reicieve that on target with SER_GetChar ().
I implemented SER_GetChar () but the code below does not go to case 'a'.
switch ( SER_GetChar() )
{
case 'a' :
dbg_print ( "Pressed 'a'\n" );
break;
default :
break;
}
What am I doing wrong ?
Any idea how to recieve input from PC keyboard on target in a debug session, to replicate uVision's functionality ?
Thank you
2024-10-15 04:35 AM
@ferro wrote:With Keil uVision I could type to a console and receive that on target with SER_GetChar ().
You've posted this in the STM32CubeIDE section - does this mean that you're now trying to get the same thing working in CubeIDE?
You'll need to show your implementation of SER_GetChar() - see the Posting Tips for how to post source code:
Is it receiving anything at all ?
What board are you using, and how is it connected to the PC?
2024-10-15 04:36 AM - edited 2024-10-15 04:42 AM
2024-10-15 04:49 AM
@Andrew Neil, thanks for prompt reply. I use CubeIDE 1.16.1, custom board and STLink v3.
extern volatile int32_t ITM_RxBuffer;
volatile int32_t ITM_RxBuffer = ITM_RXBUFFER_EMPTY;
int SER_GetChar (void)
{
return ITM_ReceiveChar();
}
Breakpoint at Line 2687 is never reached.
2024-10-15 04:51 AM
Hello @ferro ,
AFAIK, you need to retarget the "get char" to the ITM:
volatile int32_t ITM_RxBuffer=ITM_RXBUFFER_EMPTY;
int __io_getchar(void)
{
return ITM_ReceiveChar();
}
Inspired from this thread:
https://community.st.com/t5/stm32-mcus-products/itm-receivechar-void-gives-undefined/td-p/538168
2024-10-15 04:54 AM - edited 2024-10-15 04:58 AM
Right, so you're using the Instrumentation Trace Macrocell (ITM):
https://www.youtube.com/watch?v=-X8tndfqTu8
https://wiki.st.com/stm32mcu/wiki/Category:STM32CubeIDE
2024-10-15 04:59 AM - edited 2024-10-15 05:00 AM
@ferro wrote:
This means that you didn't receive any character as the buffer is empty according to the if condition.
Also, look at this article. It may help.
2024-10-15 05:41 AM
Thanks @SofLit , so far no success with your __io_getchar().
https://community.st.com/t5/stm32-mcus/how-to-use-semihosting-with-stm32cubeide-and-stm32/ta-p/49742
Thanks, might try that next.
I remembered ITM settings in uVision - is something similar in Cube ? Is ITM in Cube set for semihosting internally ?
Clearly it is a black magic to me. I checked what ITM is - part of Cortex M debuging suite. So, is not this supported by STLink ? There is GBD, STLink, some code on target, Cube. Anything else in the chain ? Cannot be Cube in control of this chain so that console printf/read is woking smoothly ? Very confusing.
@Andrew Neilthanks for the links, will take some time to get through them.
"Right, so you're using the Instrumentation Trace Macrocell (ITM):"
As I said, I have no clue what I am doing. Just trying to copy what is working (ITM) on my other project (Cortex M3, Ulink, uVision, clang) where someone else got it working. It does not need to be ITM.
2024-10-15 06:04 AM
See this video, especially at @1:12 for ITM configuration.
2024-10-15 06:07 AM
@ferro wrote:It does not need to be ITM
A common(er?) alternative would be to use a UART instead - that was the focus of my 2nd reply.