If you're diving deep enough into CircuitPython's core code, you might be dealing with the chip's peripheral registers. Now, while you can get A LOT done with breakpoints and GDB print commands, the peripheral registers can largely remain elusive. Which can be a bit of a headache at times.

Using the same PulseIn issue that has been used throughout this guide, I have been working on a replacement function to capture frequencies better. Aptly, it is named FrequencyIn. The SAMD chips can use their Timer/Counter ("TC") or Timer/Counter for Control Applications ("TCC") to capture frequency periods (and PWM...but that's for a later date). If you're interested, read the datasheet(s).

Moving on.... In order to use the TC peripheral to capture frequency periods, we have to set up the peripheral which is accomplished through the registers/helper functions. These registers are also used to check if a signal has been captured, and to retrieve the captured result. As mentioned, the elusive part is finding out if what we think is happening is actually happening at the register level.

Enter the IO Window!

Its elegantly simple. You can open the IO Window from the Debug->Windows menu. In order to read the peripheral register values, the board must be paused. The values will be updated automatically when pausing the board.

You can also SET the register values here. I may update this section later to illustrate how to use this, but since this guide is about debugging, reading the registers is beneficial on its own.

Patience Is Key

As mentioned earlier in the guide, Atmel Studio is a large program and can be buggy. One thing I constantly encounter when using the IO Window, is the time it takes to update the peripheral register values. There are a lot of them. So, exercise patience when using the IO Window. You will most likely see intermittent "Not Responding" or "Atmel Studio Is Busy" periods, and this dialog window will open:

If you're still looking for register values, click Wait 1 more minute. The dialog window may open more than once before you can get the information you seek.

If you're done looking, click Stop waiting, and AS7 will abandon the process it is trying to accomplish.

As best I can tell, this is all related to communication with the debugger and the backagent program.

This guide was first published on May 24, 2018. It was last updated on May 24, 2018.

This page (Reading Peripheral Registers) was last updated on Oct 18, 2021.

Text editor powered by tinymce.