2017-03-12 03:30 PM
Hi,
I used to use the ITM_SendChar with STM32F3 Discovery board in the past with no problem.
===
Now I wanted get an text output from another VCOM-less board - the STM32L-Discovery.
I configured the ST-LINK debugger the regular way for ITM:
XTAL=2Mhz (sourced from the ST-LINK MCU)
Core Clock=2Mhz, Trace Enable, ITM Stimulus Port:0, Unchecked Trace Events to reduce loadand re-targeted the putc() to ITM_SendChar().
Unfortunately the output is not reliable. I use Keil Debug PrintViewer as the SWV terminal:
Counter: 0
Counter: 1 ounter: 2 Counter: 3 Counter: 4 ounter: 5 ounter: 6 Counter: 7 Counter: Counter: 9 Counter: 10 Counter: 1 Counter: 12===
I added some delay in-between the consequtive ITM_SendChar() calls but did not succede.
See simple example of failing code:
#include 'stm32l1xx.h'
#include 'stdio.h'
#include 'string.h'
struct __FILE {
int dummy;
};
FILE __stdout;
int fputc(int ch, FILE *f)
{
return(ITM_SendChar(ch));
}
volatile uint32_t msTicks=0, last_msTicks=0; // counts 1ms timeTicks - global var also good for debugging
uint32_t counter=0;
void SysTick_Handler(void) {
msTicks++;
}
void ITM_PrintString(char *msg)
{
int k;
int ll=strlen(msg);
for(k=0;k<ll;k++)
{
ITM_SendChar(*(msg+k));
}
}
#define PERIOD1000
int main(void)
{
SystemCoreClockUpdate ();// to update SystemCoreClock var - add SystemCoreClock to Watch to see exact value used
SysTick_Config(SystemCoreClock/1000);// systick setup
while (1) {
if((msTicks-last_msTicks)>PERIOD)
{
printf('Counter: %d\n\r', counter);
counter++;
last_msTicks=msTicks;
}
}
}
�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?
Please share any idea I would try to narrow down the issue.
Bogdan
2017-03-12 03:39 PM
Please notice that the output messages from the printf() is generated every 1000ms (not so often).
2017-03-13 02:54 AM
Not sure I've seen the L1 do this. Make sure you have most current firmware on the ST-LINK side.
Pretty sure the HSE input is 8 MHz from the ST-LINK.