Products > Programming

STM32 logic analyzer for peripheral registers


Chris Mr:

I've been trying to get to the bottom of of how an STM32 peripheral works and came up with this idea for making an "internal logic analyzer".

Ok, you don't drill little holes and attach leads but whilst it's not a real logic analyzer it just answered all the questions I had so I though I would give it a mention.

This is basically it.. (you have to make it run with whatever you want it to)

First, run the CPU at maximum clock rate, then turn the peripheral clock rate down to as slow as it will go (divide by 64 or more compared to the CPU).  Next set the systick reload to something longer than the expected time between events of the register you are looking at - I did 10ms.

Now you write a little function that you pass the last contents of the register you want to look at, and sit in a tight loop waiting for it to change.  When it changes, save the current time and pass it back to the control code, which responds to the change and goes back to waiting for things to alter again. The loop also stores the register contents so you can spool it out later, just like a logic analyzer.

void Grab( Original)
  New = *Register
} while( New == Original);

Hope it helps someone


[0] Message Index

There was an error while thanking
Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod