Author Topic: STM32 logic analyzer for peripheral registers  (Read 3072 times)

0 Members and 1 Guest are viewing this topic.

Offline Chris MrTopic starter

  • Regular Contributor
  • *
  • Posts: 139
  • Country: gb
  • Where there's a will there's a way
STM32 logic analyzer for peripheral registers
« on: September 25, 2019, 05:35:11 pm »
Hi,

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)
do
{
  New = *Register
} while( New == Original);

Hope it helps someone
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf