cancel
Showing results for 
Search instead for 
Did you mean: 

ITM_ReceiveChar (void) gives undefined.

jdsotack
Associate II
Posted on January 11, 2012 at 21:46

Using ITM_ReceiveChar (void) I get the error  ''undefined reference to `ITM_RxBuffer'''.  I am able to successfully use ITM_SendChar() as evidenced by getting the corresponding output on my SWV Console so my problem is limited to receiving characters.  

John
4 REPLIES 4
Posted on January 12, 2012 at 00:15

''undefined reference to `ITM_RxBuffer'''

So provide a suitable definition for ITM_RxBuffer, then!
jdsotack
Associate II
Posted on January 12, 2012 at 20:15

I think you are right although I still do not receive data after defining the variable. 

My impression is that the debug tools are smart and look for the defintion of the variable ITM_RxBuffer supporting sending chars to the target if it is there.  I am guessing that the debugger writes to the memory address of ITM_RxBuffer if defined.

I am using Atollic TrueStudio 2.3 with the STM32F4 discovery board and its built in ST-LINK.  I could have something misconfigured, a coding error,  or perhaps it is not supported with my current setup.  I will be getting a high end external debugger soon and will try again then.

What was baffling me was how the data would get to that address, but if the debugger accesses the address via the symbol table needed to manually define the variable makes sense.   Thank you for your reply.

Posted on January 12, 2012 at 21:19

''My impression ... I am guessing''

 

Neither is likely to be a very successful approach - you really need to dig into the Documentation for your tools, and/or contact their Support.

''perhaps it is not supported''

 

Again, something to check with the tools Documentation  and/or Support.

rigomate2
Associate III
Posted on April 18, 2014 at 18:08

The thread is old, but if someone should ever pop in, here is the answer:

ITM_ReceiveChar()

Can not actually receive data over the SWO, in conjunction with the

ITM_SendChar()

This has the reason because the SWO is a one direction channel, from the MCU to the debugger. Although it is possible to receive data from the debugger. But for this you have to use the semihosting function of the debugger.

http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0471c/Bgbjjgij.html

You'll have to set up your semihosting libraries/redirections etc, and you need to have a semihosting enabled debugger, like Segger Jlink. So how does theITM_ReceiveChar() work? It's simple, the debugger looks for the magic variable calledITM_RxBuffer, which you need to det up manually.

volatile int32_t ITM_RxBuffer=ITM_RXBUFFER_EMPTY; // Initialize as EMPTY

If a character comes from the debugger side, then the debugger simply halts the execution of the program, and puts the data to the magic variable. TheITM_ReceiveChar() simply polls this variable. Cheers.