I am trying to get printf statements to work without using an external UART. I am following the instruction in the ARM manuals best I can and have defined and included the following:
//###################################################
#include <stdio.h>
#include "source/datatypes.h"
#define ITM_Port8(n) (*((volatile UINT8 *)(0xE0000000+4*n)))
#define ITM_Port16(n) (*((volatile UINT16 *)(0xE0000000+4*n)))
#define ITM_Port32(n) (*((volatile UINT32 *)(0xE0000000+4*n)))
#define DEMCR (*((volatile UINT32 *)(0xE000EDFC)))
#define TRCENA 0x01000000
struct __FILE { int handle; };
FILE __stdout;
/*************************************************************************
* Function Name: fputc()
**************************************************************************
* Summary: Overrides the fputc() library function to output to ITM port 0.
*
* Parameters: the character to be displayed
* a file handling structure (for stdout)
*
* Return: the input character.
*
*************************************************************************/
int fputc(int ch, FILE *f)
{
if (DEMCR & TRCENA) {
while (ITM_Port32(0) == 0);
ITM_Port8(0) = ch;
}
return ch;
}
//#####################################################
In my normal code I have include a nu,mber of
printf("At point #1/2/3/4");
statements.
Under the debugger I can follow the code and the gets to
_CODE_ACCESS int printf(const char *_format, ...)
routine which gets to my fputc()
above, goes through the routine and returns. No character can be seen in the debugger output window. I have tried configuring the probe in both JTAG and SWD mode (and moved the SOP jumper to [001] for 2 wire SWD.
In JTAG mode the process, no errors and also no printf() output.
In SWD mode is come with errors accessing the device.
What am I missing, can anybody help please??