started library to dump registers

I’ve been digging through the SAM D21 datasheet and was curious how exactly the device is configured, especially since Arduino was using peripherals in certain ways.

So, I started making a library to dump out the configuration registers:
https://github.com/drewfish/arduino-ZeroRegs

(It’s specifically NOT designed to dump out data registers, such as counters, buffers, etc.)

Here’s some sample output:

--------------------------- EIC
NMI: none
0: none
1: RISE
2: none
3: none
4: none
5: none
6: none
7: none
8: FALL
9: none
10: none
11: none
12: none
13: none
14: none
15: none
16: none
17: none
--------------------------- EVSYS
CTRL: 
CHANNEL 0x0:  --disabled--
CHANNEL 0x1:  --disabled--
CHANNEL 0x2:  --disabled--
CHANNEL 0x3:  --disabled--
CHANNEL 0x4:  --disabled--
CHANNEL 0x5:  --disabled--
CHANNEL 0x6:  --disabled--
CHANNEL 0x7:  --disabled--
CHANNEL 0x8:  --disabled--
CHANNEL 0x9:  --disabled--
CHANNEL 0xA:  --disabled--
CHANNEL 0xB:  --disabled--
USER DMAC:0 --disabled--
USER DMAC:1 --disabled--
USER DMAC:2 --disabled--
USER DMAC:3 --disabled--
USER TCC0:EV0 --disabled--
USER TCC0:EV1 --disabled--
USER TCC0:MC0 --disabled--
USER TCC0:MC1 --disabled--
USER TCC0:MC2 --disabled--
USER TCC0:MC3 --disabled--
USER TCC1:EV0 --disabled--
USER TCC1:EV1 --disabled--
USER TCC1:MC0 --disabled--
USER TCC1:MC1 --disabled--
USER TCC2:EV0 --disabled--
USER TCC2:EV1 --disabled--
USER TCC2:MC0 --disabled--
USER TCC2:MC1 --disabled--
USER TC3 --disabled--
USER TC4 --disabled--
USER TC5 --disabled--
USER TC6 --disabled--
USER TC7 --disabled--
USER ADC:START --disabled--
USER ADC:SYNC --disabled--
USER AC:COMP0 --disabled--
USER AC:COMP1 --disabled--
USER DAC:START --disabled--
USER PTC:STCONV --disabled--
USER AC1:COMP0 --disabled--
USER AC1:COMP1 --disabled--
--------------------------- GCLK
GCLK DFLL48M: GEN=0x1
GCLK FDPLL96M: --disabled-- 
GCLK FDPLL96M_32K: --disabled-- 
GCLK WDT: --disabled-- 
GCLK RTC: GEN=0x2
GCLK EIC: GEN=0x0
GCLK USB: GEN=0x0
GCLK EVSYS_0: --disabled-- 
GCLK EVSYS_1: --disabled-- 
GCLK EVSYS_2: --disabled-- 
GCLK EVSYS_3: --disabled-- 
GCLK EVSYS_4: --disabled-- 
GCLK EVSYS_5: --disabled-- 
GCLK EVSYS_6: --disabled-- 
GCLK EVSYS_7: --disabled-- 
GCLK EVSYS_8: --disabled-- 
GCLK EVSYS_9: --disabled-- 
GCLK EVSYS_10: --disabled-- 
GCLK EVSYS_11: --disabled-- 
GCLK SERCOMX_SLOW: --disabled-- 
GCLK SERCOM0_CORE: GEN=0x0
GCLK SERCOM1_CORE: --disabled-- 
GCLK SERCOM2_CORE: --disabled-- 
GCLK SERCOM3_CORE: GEN=0x0
GCLK SERCOM4_CORE: --disabled-- 
GCLK SERCOM5_CORE: --disabled-- 
GCLK TCC0_TCC1: --disabled-- 
GCLK TCC2_TC3: --disabled-- 
GCLK TC4_TC5: --disabled-- 
GCLK TC6_TC7: --disabled-- 
GCLK ADC: GEN=0x0
GCLK AC_DIG: --disabled-- 
GCLK AC_ANA: --disabled-- 
GCLK DAC: GEN=0x0
GCLK PTC: --disabled-- 
GCLK I2S_0: --disabled-- 
GCLK I2S_1: --disabled-- 
GEN 0x0:  DFLL48M/1 IDC
GEN 0x1:  XOSC32K/1
GEN 0x2:  XOSC32K/16 DIVSEL
GEN 0x3:  OSC8M/1
GEN 0x4:   --disabled--
GEN 0x5:   --disabled--
GEN 0x6:   --disabled--
GEN 0x7:   --disabled--
GEN 0x8:   --disabled--
--------------------------- NVMCTRL
CTRLB:  RWS=1 SLEEPPRM=WAKEONACCESS READMODE=NO_MISS_PENALTY
PARAM:  NVMP=4096 PSZ=64 RWWEEPROM=0
STATUS: 
LOCK:  1111111111111111
user row:  BOOTPROT=0 EEPROM_SIZE=0 REGION_LOCKS=1111111111111111
serial # 0x594A1C9A 0x514D3246 0x43202020 0xFF0A1919
--------------------------- PAC
PAC0: 
PAC1:  DSU
PAC2: 
--------------------------- PM
SLEEP:  IDLE=CPU
EXTCTRL: 
CPUSEL:  CPUDIV=1
APBASEL:  APBADIV=1
APBBSEL:  APBBDIV=1
APBCSEL:  APBCDIV=1
AHBMASK:  HPB0_ HPB1_ HPB2_ DSU_ NVMCTRL_ DMAC_ USB_
APBAMASK:  PAC0_ PM_ SYSCTRL_ GCLK_ WDT_ RTC_ EIC_
APBBMASK:  PAC1_ DSU_ NVMCTRL_ PORT_ DMAC_ USB_
APBCMASK:  SERCOM0_ SERCOM1_ SERCOM2_ SERCOM3_ SERCOM4_ SERCOM5_ TCC0_ TCC1_ TCC2_ TC3_ TC4_ TC5_ ADC_ DAC_
RCAUSE:  POR
--------------------------- PORT
PA11 D0/RX:  IN PMUX=SERCOM0:3
PA10 D1/TX:  IN PMUX=SERCOM0:2
PA14 D2:  IN INEN
PA09 D3:  IN INEN
PA08 D4:  IN INEN
PA15 D5:  IN INEN
PA20 D6:  IN INEN
PA21 D7:  IN INEN
PA06 D8:  IN INEN
PA07 D9:  IN INEN PULLDOWN
PA18 D10:  IN INEN
PA16 D11:  IN INEN
PA19 D12:  IN INEN
PA17 D13:  OUT
PA02 A0:  IN
PB08 A1:  IN
PB09 A2:  IN
PA04 A3:  IN
PA05 A4:  IN
PB02 A5:  IN
PA22 SDA:  IN PMUX=SERCOM3:0
PA23 SCL:  IN PMUX=SERCOM3:1
PA12 SPI_MISO:  IN
PB10 SPI_MOSI:  IN
PB11 SPI_SCK:  IN
PB03 LED_RX:  IN
PA27 LED_TX:  IN
PA28 USB_HOST_EN:  IN
PA24 USB_DN:  IN PMUX=USB:DM
PA25 USB_DP:  IN PMUX=USB:DP
PB22 EDBG_TX:  IN
PB23 EDBG_RX:  IN
PA22 EDBG_SDA:  IN PMUX=SERCOM3:0
PA23 EDBG_SCL:  IN PMUX=SERCOM3:1
PA19 EDBG_MISO:  IN INEN
PA16 EDBG_MOSI:  IN INEN
PA18 EDBG_SS:  IN INEN
PA17 EDBG_SCK:  OUT
PA13 EDBG_GPIO0:  IN
PA21 EDBG_GPIO1:  IN INEN
PA06 EDBG_GPIO2:  IN INEN
PA07 EDBG_GPIO3:  IN INEN PULLDOWN
PA03 AREF:  IN
--------------------------- RTC
MODE:  2
CTRL:  PRESCALER=1024 CLKREP
READREQ: 
EVCTRL: 
FREQCORR:  0x0
ALARM:  00-00-00 00:00:00
MASK:  SS
--------------------------- SERCOM0 USART
CTRLA:  CMODE=ASYNC CPOL=RISING DORD=MSB SAMPR=0x0 SAMPA=0x0 FORM=USART RX=PAD3 TX=PAD2
CTRLB:  CHSIZE=8bit TXEN RXEN
BAUD:  0xFF2D
--------------------------- SERCOM1
--disabled--
--------------------------- SERCOM2
--disabled--
--------------------------- SERCOM3 I2CM
CTRLA:  SDAHOLD=DIS SPEED=SM<100kHz,FM<400kHz INACTOUT=DIS
CTRLB: 
BAUD:  0xEF
--------------------------- SERCOM4
--disabled--
--------------------------- SERCOM5
--disabled--
--------------------------- SYSCTRL
PCLKSR:  XOSC32KRDY OSC8MRDY DFLLRDY DFLLLCKF DFLLLCKC BOD33RDY B33SRDY
XOSC:  --disabled--
XOSC32K:  XTALEN EN32K RUNSTDBY ONDEMAND STARTUP=2000092us
OSC32K:  --disabled--
OSCULP32K:  CALIB=0x11
OSC8M:  PRESC=1 CALIB=0x80D FRANGE=8-11MHz
DFLL:  MODE QLDIS WAITLOCK
BOD33:  ACTION=RESET PSEL=1 LEVEL=0x7
VREG: 
VREF:  CALIB=0x60
DPLL:  --disabled--
--------------------------- WDT
--disabled--

Even though I haven’t (yet?) created dumps for all the peripherals, I hope it’s useful.

Hehe, forgot to mention that I made it to share, so feel free to try it out.

Useful. I'm trying route a signal from a pin to a counter, which means getting it through the EIC, EVSYS and then to to counter. Helps me see which bits are not set and helps figure out how to set bits too!

Cool, glad you found it useful. I’ve been playing with the TCs lately as well so might implement them next. I also realized that I misunderstood some things in my first reading of the datasheet, so I suspect that all those INTENSET registers might be useful to print.