Loading...
 

Zephyr project on STM32

   Zephyr Workbench, a VSCode extension to manage Zephyr on STM32.
It enables users to easily create, develop, and debug Zephyr applications.
Main features:
  • Install host dependencies.
  • Import toolchain and SDK.
  • Create, configure, build and manage apps.
  • Debug STM32.
You can directly download it from the VSCode marketplace
For more details, visit the Zephyr Workbench

System Workbench for STM32


Strange behaviour of SWD in atollic stm32 nucleo

Hello ;)
I want just configure SWD debbuger in Atollic to write some data, for first via ITM_SendChar.
So my main is:
while (1)
{
ITM_SendChar( 65 );
ITM_SendChar(‘D’);
HAL_GPIO_WritePin(LD2_GPIO_Port, LD2_Pin, GPIO_PIN_RESET);
HAL_Delay(500);
HAL_GPIO_WritePin(LD2_GPIO_Port, LD2_Pin, GPIO_PIN_SET);
HAL_Delay(500);
printf(“test”);
}
I get only once “AD”, but LED is blinking all the time and printf don’t work at all.

I will add that when I run program in VIsual Studio with VisualGDB extension it works and I get any information I want.
I try debug via ST-LINK Utility but there is the same problem I get only once “AD” and LED is blinking all the time.
Config

Hi adi,

Lookng at your screenshot it seems that you dont have very many events happening from an SWV point of view. Just ITM0, DWT0 and time stamps. From where is the variable “value” written? Is it possible that this is done very frequently from some interrupt not visible in your code snippet above?
What I am asking is if you see that you get a lot of overflows? You can see the overflow count in the view called “SWV Trace log”, down left corner if I am not mistaken.

Could you also show us how your printf looks? Maybe Atollic run-time libraries differ from VisualStudio. In TrueSTUDIO you will need to bring in “tiny_printf.c” this function calls “_write” function. “_write” stub is available in the file called “syscalls.c”. You need this one too, and there you need to instrument _write to call ITM_SendChar. Before that is done “printf” is not directed to ITM0.
These two c-files can be added to your project by File - New - Other - filter for the “syscalls” or “printf”. Put them in src folder.

Does that solve the problem?


Thanks for answer.
My _write function in syscalls is
int _write(int32_t file, uint8_t *ptr, int32_t len)
{
int i=0;
for(i=0 ; i < len ; i++)
ITM_SendChar((*ptr++));
return len;
}
My “value” variable is global and there is only written 50. I don’t need printf for now, I try only write single character via ITM_SendChar().
I don’t have interrupt enabled.
This is my SYS configuration:
Cube
When I disable time stamps and ITM0 there is still the same problem. LED blinking and get “AD” only once.

Sounds quite strange. I wonder if the CPU resets for some reason..

Put a breakpoint in ITM_SendChar() on the line: which says:
ITM->PORT0.u8 = (uint8_t) ch;

I assume that you arrive here first time “AD” is printed.
What happens next iteration when it is time to print? Do you hit the breakpoint? If not, the condition in the if-statement in ITM_SendChar() not met? See if/how they differ between successful print and unsuccessful print.

Use breakpoints to verify that you actually exercise the code. Does that give you any new insights?


 

Newest Forum Posts

  1. Монтаж камина с грилем в Москве - установка и барбекю by KpddomErorb, 2025-05-10 18:28
  2. SPI on Nucleo_STMH533RE by royjamil, 2025-05-04 20:13
  3. SPI on Nucleo_STMH533RE by higginsa1, 2025-03-25 07:37
  4. SPI on Nucleo_STMH533RE by royjamil, 2025-03-23 11:31
  5. SPI on Nucleo_STMH533RE by higginsa1, 2025-03-23 09:33
  6. Configuring DMA for ADC in SW? by sam.hodgson, 2025-03-04 12:58
  7. Build a project in "release" mode by info@creosrl.it, 2025-02-20 18:12
  8. Build a project in "release" mode by info@creosrl.it, 2025-02-20 17:05
  9. Build a project in "release" mode by tang, 2025-02-20 10:36
  10. Build a project in "release" mode by info@creosrl.it, 2025-02-19 17:35

Last-Modified Blogs