Skip to main content
GHrib.1
Associate III
November 22, 2022
Solved

Is it possible to view registers of a running target inside STM32Cube?

  • November 22, 2022
  • 6 replies
  • 4949 views

I would like to view/modify values of registers while in debugging perspective, while the target is in running state. So far I have discovered that you can view registers only during pause(resume) of program in the SFRs window. Is it possible to have some type of continous refresh of registers values?

This topic has been closed for replies.
Best answer by MM..1

In your code create u16 variable and insert SFR for monitor to it in some refresh code place. For example systick int .

_IO uint16_t mon_odr;
 
mon_odr= GPIOx->ODR;

6 replies

MM..1
Chief III
November 22, 2022

Maybe yes in live expression, and change in pause over bit access

S.Ma
Principal
November 22, 2022

Yes live watch or live expression is one way. While the code runs, the debug interface is used to make a memory read access stealing a bus cycle, like a dma would. Of course it is not real time. Something I didn't use was watchpoint, it is like breakpoint on data value matching. If supported, can give other ways to debug a code.

GHrib.1
GHrib.1Author
Associate III
November 23, 2022

How can I view register in Live Expressions window?

Lets say I have a simple blink program, the values inside GPIOA_ODR register should change. How can I see this change?

If I write GPIOA_ODR inside Live Expressions I get Failed to Evaluate Expression inside value space.

Tesla DeLorean
Guru
November 22, 2022

Which registers? The MCU's ?

With peripheral registers it gets to be a bit invasive. The stuff in general can change millions of times a second..

What exactly are you trying to achieve? Perhaps there's a better way or approach?

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
GHrib.1
GHrib.1Author
Associate III
November 23, 2022

The more the better, but i would be satisfied with peripheral registers (TIM, DMA, ADC).

That is true, but when I worked with Texas Instruments CCS I found it very useful, even though it is not real time. I found it very useful for debugging strange behavior of peripherals, where registers are your only source of information.

I don't have a specific problem yet, I am only preparing for them.

Lets say that I have simple blink program, GPIOA_ODR register should therefore change its value. How can I see this change in registers value during debugging?

Semer CHERNI
ST Employee
November 23, 2022

Hello @Gašper Hribar​ 

First let me thank you for posting.

To watch the IP register, the STM32CubeIDE provide a specific view for this purpose called SFRs:

0693W00000WJJD0QAP.png 

I hope this answer solve your question. If yes, please mark the answer as a Best Answer.

Semer.

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.
GHrib.1
GHrib.1Author
Associate III
November 23, 2022

I am familiar with SFR window. The problem I have is the fact, that this view doesn't show changing of registers values during runtime (values update only on "pause").

Rim LANDOLSI
ST Employee
November 23, 2022

Hello GHrib.1,

For live update you can use live expressions view.

CubeIDE 1.11.0 to be released soon will include live update from the SFR view .

GHrib.1
GHrib.1Author
Associate III
November 23, 2022

How can I use live expressions view to look into registers?

Lets say I have a simple blink program, the values inside GPIOA_ODR register should change. How can I see this change?

If I write GPIOA_ODR inside Live Expressions I get Failed to Evaluate Expression inside value space.

I am very happy to hear about it :D . It would also be great if the opened registers inside SFR view would stay opened after changing perspective (DEBUG->EDIT->DEBUG). Currently I have to open registers I am interested in every time I go into DEBUG perspective.

MM..1
MM..1Best answer
Chief III
November 23, 2022

In your code create u16 variable and insert SFR for monitor to it in some refresh code place. For example systick int .

_IO uint16_t mon_odr;
 
mon_odr= GPIOx->ODR;

Jot.eS
Visitor II
November 25, 2022

You must use the memory address of the register.

E.g. if the address of GPIO_ODR is 0x40020014, then you have to write *0x40020014 in the live expression window. Please note the asterisk in front of the address.

GHrib.1
GHrib.1Author
Associate III
November 25, 2022

Thank you, I got some response, but it isn't best for readability. Live expression view presumes that this pointer is pointing to an integer, which is correct (register is 32-bit). If you want to see the values of register bit by bit, you have to convert int to binary. My question is if i can somehow tell the Live expression that i would like to see only one bit?