Debug with SWO on stm32f4discovery and IAR EW
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2015-01-20 3:27 PM
Posted on January 21, 2015 at 00:27
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:- SWO Configuration CPU Clock set to: 144 MHz (the one that works with St-link utility)
- ITM Stimulus Ports all the 0 ports checked.
- SWO Clock: Autodetect.
- Library: Full
- Semihosted
- stdout/stderr Via SWO
- Interface: SWD
- CPU Clock: 144MHz
- SWO Clock: Auto (2000Khz same as St-link utility)
#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
This discussion is locked. Please start a new topic to ask your question.
2 REPLIES 2
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2015-01-20 5:17 PM
Posted on January 21, 2015 at 02:17
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=166
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Up vote any posts that you find helpful, it shows what's working..
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2015-01-21 8:32 AM
Posted on January 21, 2015 at 17:32
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.