cancel
Showing results for 
Search instead for 
Did you mean: 

Advancing debug steps clock by clock

Amir1
Associate II

Hello All

I understand that debug steps advance instruction by instruction (whether in C or assembly). I wonder if there is any way to advance CPU clock by CPU clock. I need this to debug an issue I have with the SysTick timer.

Thanks

5 REPLIES 5

Certainly not in some simple way accessible through a few clicks in an IDE.

> I need this to debug an issue I have with the SysTick timer.

Maybe you want to tell us about this issue, in a new thread.

JW

Thanks. It would be nice to have that capability.

The issue is resolved. I was trying to use one of the SysTick timer bits to toggle a pin, and the intended frequency was too high given that I was using an if loop to set the gpio register. I wrongly attributed the lousy waveform to the timer. Nonetheless, it would be very nice if one could advance the debugger clock by clock sometimes.

Since we are here I should ask you this. Is that possible in STM32 to assign a particular bit of a variable to a particular bit of the ODR (I guess that is called atomic access in embedded programming lingo)? If the answer is yes, then my "if" loop becomes moot as I would be able to directly assign the desired timer bit (which I can extract by a simple mask) to the desired ODR bit.

There is bit-banding, but it is not good for peripherals because the smoke-n-mirrors to implement it aren't actually atomic. Same as doing RMW on TIM->SR there is a pretty large window to induce a hazard.

The GPIO has a 32-bit wide BSRR register which allows an bits within the 16-bit GPIO Bank to be set High or Low atomically without disturbing other bits/pins.

The CPU is static, I guess you could pulse the clock input one edge at a time if you really wanted too. But, in all honestly the silicon isn't going to implement a whole lot of magic debug functionality, for the ppb cases. The ITM/DWT/ETM stuff should cover most bases. But a whole lot of other pieces are clocking along autonomously from the processor. Get a trace pod for deeper analysis, and how-did-I-get-here problems. Usually cheaper just to instrument your code to understand flow and dynamic behaviour.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

Thanks. The BSRR was a good idea, and, on that basis, I replaced the if loop with assignments. I am super new to this area and appreciate such guidance. Will have to learn the tools you mentioned bit by bit.

> The CPU is static

Are you *sure*, Clive?

And how's the fabric around?

I was about to write the same in the morning, but then thought otherwise and had a look at the HSE-bypass specification in 'F407 datasheet. And guess what, it has a lower bound.

Yes I know it may be only the limitation of the semi-analog HSE cell, but...

Jan