Showing results for 
Search instead for 
Did you mean: 

Please guide me

Associate III

I have stm32 board :



and would like to make a simple helo word code in C and see out put by SWD debug connector in ITM unit (FIFO), 
SO i create simple hello word as follow:
IDE : stm32cubeide
New > stm32 project > chose above board , 
main.c :
#include <stdint.h>
int main(void)
printf("Hello World\n");
    /* Loop forever */
then add this code to syscalls.c as i found in internet :

// Implementation of printf like feature using ARM Cortex M3/M4/ ITM functionality
// This function will not work for ARM Cortex M0/M0+
// If you are using Cortex M0, then you can use semihosting feature of openOCD

//Debug Exception and Monitor Control Register base address
#define DEMCR         *((volatile uint32_t*) 0xE000EDFCU )

/* ITM register addresses */
#define ITM_STIMULUS_PORT0   *((volatile uint32_t*) 0xE0000000 )
#define ITM_TRACE_EN           *((volatile uint32_t*) 0xE0000E00 )

void ITM_SendChar(uint8_t ch)

//Enable TRCENA
DEMCR |= ( 1 << 24);

//enable stimulus port 0
ITM_TRACE_EN |= ( 1 << 0);

// read FIFO status in bit [0]:
while(!(ITM_STIMULUS_PORT0 & 1));

//Write to ITM stimulus port0

build and it work good, 
connect board by mini usb to PC USB
and as I check window , it connect and working
finally try to debug but IDE give error message : 
No ST-Link detected , Please connect ST-link and restart the debug session,
Please recommend if i miss some point ?
thank you in advance
ST Employee

Hello @CG3 

Could you please try using an other USB port on your PC and ensure that you are using a USB data cable and not a charging cable. Finally, don't forget to check that all the steps of the part 3.1 of the UM2179 are verified.

Best Regards.


To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.