2015-06-11 04:14 AM
Hi i am new to embedded system programming and stumbled upon this basic problem of re-directing output to the ITM Port0. I read multiple posts on the same but sadly I cant get it to work. I shall try to be as descriptive as possible. I am following the lab mentioned here http://www.keil.com/appnotes/files/apnt_230.pdf Page 15 Section 19.
Board : STM32F407 Discovery boardKeil 5.15 MDK /*---------------------------------------------------------------------------- * CMSIS-RTOS 'main' function template *---------------------------------------------------------------------------*/&sharpdefine osObjectsPublic // define objects in main module&sharpinclude ''osObjects.h'' // RTOS object definitions&sharpdefine ITM_Port8(n) (*((volatile unsigned char *)(0xE0000000+4*n)))/* * main: initialize and start the system */int main (void) { int value = 1; osKernelInitialize (); // initialize CMSIS-RTOS // initialize peripherals here // create 'thread' functions that start executing, // example: tid_name = osThreadCreate (osThread(name), NULL); ITM_Port8(0) = value ; while(ITM_Port8(0) == 0); ITM_Port8(0) = 0x0D; while(ITM_Port8(0) == 0); ITM_Port8(0) = 0x0A; osKernelStart (); // start thread execution } I know the settings for the core clock speed are important so i set it correctly to 168MHz . Here is the snapshot to be sure. http://imgur.com/jSiUY2a,bqdc5c9&sharp1What am i missing here ? Seems my debug view gets nothing . Any help for me ? #stm32f-printf2015-06-11 06:04 AM
I'd probably check the 'Port 0..7' option, and use the ITM_SendChar() function.Posted some non RTX examples of using the SWV and Keil to the forum.
https://community.st.com/0D50X00009XkgG8SAJ
Might want to update the ST-LINK firmware, looks rather dated.Edit: Fixed DEAD LINK, original post from 11-Jun-2015
2015-06-11 12:32 PM
// STM32F4-DISCO SWV DEMO - sourcer32@gmail.com
// Make sure SB12 is make, and trace speed matches core frequency as built
#include <
stdio.h
>
#include ''stm32f4_discovery.h''
//****************************************************************************
void ITM_SendString(char *s)
{
while(*s)
ITM_SendChar(*s++);
}
//****************************************************************************
int main(void)
{
int i;
volatile int j;
ITM_SendString(''SWD Testing
'');
printf(''Hello World!
'');
i = 0;
while(1) /* Infinite loop */
{
ITM_SendString(''0123456789 '');
if ((i++ & 0x07) == 0x07)
ITM_SendString(''
'');
for(j=0; j<
10000000
; j++);
}
}
//******************************************************************************
// Hosting of stdio functionality through SWV - Serial Wire Viewer
//******************************************************************************
#include <rt_misc.h>
#pragma import(__use_no_semihosting_swi)
struct __FILE { int handle; /* Add whatever you need here */ };
FILE __stdout;
FILE __stdin;
int fputc(int ch, FILE *f)
{
ITM_SendChar(ch);
return(ch);
}
int fgetc(FILE *f)
{
char ch;
ch = '?';
return((int)ch);
}
int ferror(FILE *f)
{
/* Your implementation of ferror */
return EOF;
}
void _ttywrch(int ch)
{
ITM_SendChar(ch);
}
void _sys_exit(int return_code)
{
label: goto label; /* endless loop */
}
//****************************************************************************
#ifdef USE_FULL_ASSERT
/**
* @brief Reports the name of the source file and the source line number
* where the assert_param error has occurred.
* @param file: pointer to the source file name
* @param line: assert_param error line source number
* @retval None
*/
void assert_failed(uint8_t* file, uint32_t line)
{
/* User can add his own implementation to report the file name and line number,
ex: printf(''Wrong parameters value: file %s on line %d
'', file, line) */
/* Infinite loop */
while (1)
{
}
}
#endif
//******************************************************************************