Skip to content

Commit 726e04b

Browse files
committed
documentation updated
1 parent 2ae58d1 commit 726e04b

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

README.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ Take Arduino low power projects for the SAM D21 to the next level.
1717

1818
## Motivation
1919

20-
There are already several libraries available for the SAM D21 MCU that support low power features:
20+
There are already several libraries available for the SAM D21 MCU that support low power features, e.g.:
2121

2222
- [Arduino Low Power library](https://github.com/arduino-libraries/ArduinoLowPower)
2323
- [RTCZero Library for Arduino](https://github.com/arduino-libraries/RTCZero)
2424

2525
They provide solutions for specific use cases but fall short of making full use of the potential of the SAM D21 MCU. E.g. none of them tries to disable the USB module at runtime, the most power hungry function of the MCU, although typically not required for low power usage.
2626

27-
Another part of the problem is the rigid way the Arduino Core for SAM D21 bootstraps the MCU for 48 MHz with most MCU features enabled and configured for maximum performance. In contrast to classic Arduino MCUs like the Atmel ATmega 328 the SAM D21 MCU supports up to 9 clock sources at the same time, that may run in parallel at different frequencies. Using the generic clock controller (GCLK) the clocks can be selectively assigned to different MCU modules and can be stopped in standby mode. Combined with the power manager (PM) this allows disabling unused MCU modules and running the required MCU modules with clock frequencies that are optimized for the use case.
27+
Another part of the problem is the rigid way the Arduino Core for SAM D21 bootstraps the MCU for 48 MHz with most MCU features enabled and configured for maximum performance. In contrast to classic Arduino MCUs like the Atmel ATmega 328 the SAM D21 MCU supports up to 9 clock generators at the same time, that may run in parallel at different frequencies. Using the generic clock controller (GCLK) the clocks can be selectively assigned to different MCU modules and can be stopped in standby mode. Combined with the power manager (PM) this allows disabling unused MCU modules and running the required MCU modules with clock frequencies that are optimized for the use case.
2828

2929
Although the main key, the power saving options of the SAM D21 are not exhausted by controlling clocks on the module level. The SAM D21 MCU has an ARM Cortex M0+ CPU core that knows an operation mode called [sleep-on-exit](https://community.arm.com/arm-community-blogs/b/architectures-and-processors-blog/posts/beginner-guide-on-interrupt-latency-and-interrupt-latency-of-the-arm-cortex-m-processors). This mode is useful if the application does not need a main loop but runs completely event/interrupt driven. This saves the CPU overhead for the double context switch between main loop, ISR and back, saving power and reducing ISR latency.
3030

@@ -36,6 +36,7 @@ There are also individual hardware aspects of each board to consider that may ad
3636

3737
Note that this library was designed and tested for the SAM D21 but will probably work with other SAM D variants with little or no adjustment, especially with the SAM DA1 variant.
3838

39+
3940
## MCU Power Management
4041

4142
Well known from other CPUs and MCUs effective power management can be achieved by the combination of several aspects:
@@ -56,6 +57,7 @@ The [System](src/System.h) class supports the following operations:
5657
- configure/enter sleep mode (idle 0-2 or standby)
5758
- enable/disable sleep-on-exit ISR mode
5859
- disable all non essential modules incl. *USB*
60+
- cache the ISR vector table in SRAM
5961
- read the MCU serial number
6062

6163
In this list the **reduction of the main clock** is not included. Changing this clock at any time is possible but in combination with the Arduino framework this is typically not a good choice as several Arduino libraries assume that the main clock frequency *F_CPU* is fixed at compile time. Changing it at runtime to a different value will result in the loss of various functions, especially everything that is timing related (e.g. millis() will no longer be real milliseconds). As the Arduino Core for SAM D21 only supports F_CPU fixed to 48 MHz, a patch if provided for [startup.c](patches/Seeduino-hardware-samd-1.8.3/startup.c) and [boards.txt](patches/Seeduino-hardware-samd-1.8.3/boards.txt) to support alternative values of 32, 24, 16, 12, 8, 6, 3 and 1.5 MHz. The provided patch is for the Seed Studio XIAO SAM D21, but this patch can also applied to any other SAM D21 MCU with no or little changes.
@@ -69,15 +71,15 @@ Using these functions, especially combined, can reduce the average runtime power
6971

7072
Compared to the extensions included in the Arduino core for the ESP8266 the Arduino core for the SAM D21 is rather sparse. Three more classes are included in this library to provide several missing features:
7173

72-
| Class | Extensions |
73-
| ----------------------- | ---------------------- |
74+
| Class | Extensions |
75+
| ----------------------- | ----------------------------- |
7476
| Analog2DigitalConverter | Selectable Gain, Hardware Averaging, Temperature Sensor, Supply, Core and Bandgap Voltage, Callback |
75-
| RealTimeClock | Counter Mode, Callback |
76-
| TimerCounter | Callback |
77+
| RealTimeClock | Counter Mode, Callback |
78+
| TimerCounter | Callback, delay() replacement |
7779

7880
The *RealTimeClock* class of this library provides RTC counter mode as an alternative to the calendar mode of the RTCZero library. The *Analog2DigitalConverter* class and the *TimerCounter* can be used alternatively or combined with Arduino framework functions if the documented conditions are observed.
7981

80-
The external interrupt controller (EIC) is one of the MCU modules where Arduino framework functions like attachInterrupt() can be used in the familiar way and the low power optimization can be achieved by a call to the *System* class.
82+
The external interrupt controller (EIC) is one of the MCU modules where Arduino framework functions like *attachInterrupt()* can be used in the familiar way and the low power optimization can be achieved by a call to the *System* class.
8183

8284
On the other hand the SPI implementation of the Arduino Core for SAM D21 does not use *F_CPU* or *SystemCoreClock* for determining the SPI baud rate divider but a hardcoded value of 48000000 (*SERCOM_SPI_FREQ_REF*), preventing correct baud settings at alternative main clock frequencies. To work around this without changing the Arduino Core source it is necessary to scale the baud rate with the following formula:
8385

0 commit comments

Comments
 (0)