Atmel SAM D10

Timers

The D10 has two identical TC (timer/counter) modules, along with a TCC (timer/counter for control) module. The TC module is a 16-bit auto-reload counter with two capture/compare channels. The two TC modules can be paired together to form a single 32-bit TC module.

TCC is a 24-bit auto-reload timer with 4 capture/compare channels that has several capabilities and output modes designed for control applications

AtmelStudio_2017-08-09_19-41-41.png
Which of these #ifdefs are enabled? Your guess is as good as mine; Atmel Studio is Visual Studio without Microsoft’s excellent IntelliSense engine, making it worse than even Keil µVision in terms of text-editing productivity — and far inferior to the Eclipse- and NetBeans-based IDEs from competitors. I added 6 publicly-visible global variables in this file among others in the project, and none of them appear in the auto-complete list.

Atmel Studio

While many vendors have transitioned to Eclipse-based IDEs, Atmel went with a Visual Studio Isolated Shell-based platform in Atmel Studio. I do a ton of .NET and desktop-based C++ development, so I expected to feel right at home in Atmel Studio when I first launched it. Unfortunately, Microsoft calls this product “Visual Studio Isolated Shell” for a reason — it’s simply a “shell” of Visual Studio, without any of the meat. The excellent IntelliSense engine that Microsoft spent years trying to get right (even for large, complex C++ projects) has been replaced by some sort of Atmel-proprietary “Visual Assist” technology.

chrome_2017-08-09_20-27-37
While Atmel START provides a nice-looking graphical interface especially useful for the flexible clocking schemes available on modern ARM microcontrollers, its design validation is hit or miss: in this picture, there’s absolutely no warning that the main 32 kHz oscillator isn’t enabled. Most seriously, the DFLL module indicates it’s outputting a frequency of 48 MHz, even though its multiplier is set to “0” in the configuration properties dialogue. Changing this to arbitrary values does not update the “48 MHz” display. This is a tool you cannot trust.

Atmel START is the web-based code-gen tool that Atmel rolled out for its AVR and ARM processors a few years ago in response to the popularity of code-gen tools. It provides a nice graph-based clock editor, pin muxing (with a footprint view of the chip), and peripheral initialization and basic run-time support. Once you’ve configured the project to your liking, you can download the configuration file, or download a generated project package for Atmel Studio, IAR EW, Keil µVision, or a Makefile-based project. The last format may seem strange, but Atmel has an extremely vocal hobbyist crowd that uses Linux/macOS as a primary embedded development platform (which precludes them from using Atmel Studio), and these people love CLI-based build tools.

In terms of the style of code generation, Atmel START is what I call a “hybrid code generator” — it generates configuration structures which it then passes to runtime peripheral libraries. Instead of generating functions that strictly initialize registers to predefined constant values (fast!), this style of code-gen tool produces bulkier, slower code that must be evaluated at runtime to calculate baud rates, divider values, clock source settings, etc. The advantage of this style of tool is that you have more control as to when and how the initialization routines are called — and you can use the code-gen tools as a one-time launchpad for your project, instead of relying it constantly as you work your way through design changes.

Atmel START has some shortcomings: all projects must originate in the web browser, which presents a clunky workflow when compared to truly integrated code-gen tools (or even code-gen tools that are written in a native software framework). Strangely, you can edit Atmel START projects inside Atmel Studio (and re-gen the code when you’re done) — so why can’t you start an Atmel START project from Atmel Studio in the first place?

chrome_2017-08-09_20-45-32.png
It’s not clear to me how it’s possible to independently configure a PWM channel’s total period, pulse duration, and duty cycle (aren’t these dependent on each other?); yet Atmel Studio has separate inputs for each of these. I assumed that if I changed one the other ones would update accordingly, but that’s not the case.

The second problem is much more serious: there’s essentially no error-checking done by Atmel SMART. It will gladly generate a project that has no functional oscillator, or one that has the DFLL set to an invalid frequency, or one that doesn’t have the proper number of wait-states set for the flash controller.

And, not surprising at this point: don’t expect to be have any useful explanation or documentation in SMART. There is no information inside the tool that explains what a particular setting does, or what its acceptable input values are. This is a tool that may save you from typing, but it certainly won’t save you from reading the datasheet.

Most of the reasons I use code-gen tools is to avoid goofing up silly stuff like that, and Atmel START did not help in that regard at all. I spent way too much time trying to get past a check-oscillator-ready loop before realizing that while my 32 kHz oscillator module was enabled and routed properly, I didn’t tick the “Enable 32 kHz Output” checkbox (as I assumed that was related to some sort of clock-out peripheral pin function — again, no docs in Atmel START). Any decent code-gen tool I’ve ever used has issued warnings in cases like this (or flat-out refused to generate code).

Exacerbating this problem, Atmel START has a “Frequency: 32.768 kHz” label under the clock module, regardless of state. Is this a software drawing bug, or a design decision? The most serious problem is in the same vein: there’s several persistent text strings displayed that absolutely must be considered bugs; most notably, with two of the three projects I generated, the DFLL text display was stuck at “48 MHz” — regardless of what the DFLL multiplier was actually set to. This is a serious flaw that makes me nervous whenever using Atmel START — this is a tool I cannot trust.

 

 

Performance

Toggle

The Atmel SAM D10 has single-cycle I/O operations that bypass the AHB interface altogether; coupled with the M0+’s 2-cycle branch instruction and Atmel’s flash caching yielded a three-cycle bit-wiggle time.