2015-01-20 03:27 PM
I read absolutely all the posts in this forum plus some other posts online and I can't still make this work with IAR and the Terminal I/O screen.
I can however make it work using the ST-Link Utility and the Printf via SWO. But I can't have both running at the same time and I would like to debug completely with IAR. SWO Config on debug screen:#include ''stdio.h''
static
void
TextOut(
const
char
*str);
int
main(
void
)
{
TextOut(
''It works!''
);
}
void
TextOut(
const
char
*str)
{
do
{
if
(*str==
'\n'
) ITM_SendChar(
'\r'
);
ITM_SendChar(*str);
}
while
(*str++);
}
This works perfectly in ST-Link Utility, and I can read the ''It works!''.
But if I debug it with IAR it gets stuck inside
core_cm4.h:
__STATIC_INLINE uint32_t ITM_SendChar (uint32_t ch)
{
if
((ITM->TCR & ITM_TCR_ITMENA_Msk) &&
/* ITM enabled */
(ITM->TER & (1UL << 0) ) )
/* ITM Port #0 enabled */
{
while
(ITM->PORT[0].u32 == 0);
ITM->PORT[0].u8 = (uint8_t) ch;
}
return
(ch);
}
It gets stuck on line 6:
while
(ITM->PORT[0].u32 == 0);
And nothing shows up in the Terminal I/O screen.
Any ideas why is this happening? And why the exact same code would work on ST-Link Utility?
Thanks
2015-01-20 05:17 PM
Try the Debug_ITMDebugEnable() function from here, different debuggers may configure the CPU in slightly different ways. Print out the debug/itm registers if you want to see the differences.
printf(''%08X %08X %08X\n'',*SCB_DEMCR,*ITM_TCR,*ITM_TER);[DEAD LINK /public/STe2ecommunities/mcu/Lists/STM32Discovery/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/STM32Discovery/Programmable%20CRC%20peripheral%20in%20newer%20STM32%20devices&FolderCTID=0x01200200770978C69A1141439FE559EB459D75800084C20D8867EAD444A5987D47BE638E0F¤tviews=166]https://my.st.com/public/STe2ecommunities/mcu/Lists/STM32Discovery/Flat.aspx?RootFolder=%2Fpublic%2FSTe2ecommunities%2Fmcu%2FLists%2FSTM32Discovery%2FProgrammable%20CRC%20peripheral%20in%20newer%20STM32%20devices&FolderCTID=0x01200200770978C69A1141439FE559EB459D75800084C20D8867EAD444A5987D47BE638E0F¤tviews=1662015-01-21 08:32 AM
Thank you Clivel.
The main reason I was trying to send messages directly through ITM is because printf() wasn't working at all.But it looks like I messed around with some other settings from IAR, after I tried with a new project I could use printf() and get the messages without problems. So I am using that right now.Thanks, I might need to use a CRC peripheral in the near future.