MPAE-15126 Readme File formatting post Final review

master
Amey Panse 2023-02-13 09:23:32 +05:30
rodzic dc5d2301ee
commit 72e423a65d
3 zmienionych plików z 39 dodań i 39 usunięć

Wyświetl plik

@ -4,7 +4,7 @@
# Configure the External 32.768 kHz Crystal as an RTC Clock Source in Sleep Mode Using AVR128DB48
This code example demonstrates how to configure an external 32.768 kHz crystal as a clock source to the Real-Time Counter (RTC) module of AVR microcontrollers. In this code example, the RTC module of AVR128DB48 microcontroller is supplied with an external 32.768 kHz crystal clock source while the microcontroller is in Sleep mode (Power-Down mode). It will show the power consumption by the device in Sleep mode and how external crystal as clock is accurate and consumes less power than the internal high frequency (HF) oscillator.
This code example demonstrates usage of AVR128DB48 microcontroller for configuring external crystal as peripheral clock source in sleep. In this example, external crystal as peripheral clock source in sleep is exemplified using Real-Time Counter(RTC).
## Introduction
@ -17,7 +17,7 @@ In many applications which are battery operated, the microcontroller is dependen
## Description
The objective of this code example is to enable low-power "Power-Down" mode in the microcontroller and configure the RTC module to operate in PIT mode using an external 32.768 kHz crystal oscillator, and completely shut down the microcontroller system clock and peripherals. Thereby, the microcontroller wakes up from Sleep to PIT. This implementation helps to minimize the microcontroller average power consumption. For the demonstration purpose, the switch event is used to switch to the external crystal oscillator as the clock source and lets the microcontroller enter Sleep mode. After the RTC period elapse, the PIT interrupt occurs and the clock source for the microcontroller switches back to the internal HF oscillator and is in Active mode.
The objective of this code example is to enable low-power "Power-Down" mode in the microcontroller and configure the RTC module to operate in PIT mode using an external 32.768 kHz crystal oscillator, and completely shut down the microcontroller system clock and peripherals. Thereby, the microcontroller wakes up from Sleep to PIT interrupt. This implementation helps to minimize the microcontroller average power consumption. For the demonstration purpose, the switch event is used to switch to the external crystal oscillator as the clock source and lets the microcontroller enter Sleep mode. After the RTC period elapse, the PIT interrupt occurs and the clock source for the microcontroller switches back to the internal HF oscillator and is in Active mode.
<p align="center">
<img width=600 height=auto src="images/blk_diag.png">
@ -44,13 +44,38 @@ MPLAB® X IDE compiler and graphical code generators are used throughout the app
## Application Firmware
The example firmware uses the RTC peripheral to showcase the working of a microcontroller in Sleep mode by using 32.768 kHz external crystal oscillator as its clock source. During the active period, the system uses the 4 MHz internal oscillator. The Sleep control system peripheral is configured in Power-Down mode with the Performance mode being set to auto. Here, in Power-Down Sleep mode, only the Periodic Interrupt Timer functionality is available. The PIT uses the same clock source as RTC. The RTC period is configured for 30s. If a switch press event is detected, the RTC peripheral gets enabled, and the system enters the Power-Down mode. The RTC flag is monitored to check if the RTC period is completed via the Interrupt Service Routine (ISR). After the RTC period of 30s is completed, the device wakes up from Sleep. As soon as it wakes up, the RTC peripheral gets disabled and the MCU continues to stay in Active mode until a new switch press event is detected.
The example firmware uses the RTC peripheral to showcase the working of a microcontroller in Sleep mode by using 32.768 kHz external crystal oscillator as its clock source. During the active period, the system uses the 4 MHz internal oscillator. The Sleep control system peripheral is configured in Power-Down mode with the Performance mode being set to auto. Here, in Power-Down Sleep mode, only the Periodic Interrupt Timer functionality is available. The PIT uses the same clock source as RTC. The PIT interrupt period is configured for 30s. If a switch press event is detected, the PIT functionality gets enabled, and the microcontroller enters the Power-Down mode. After the period of 30s is completed, the PIT generates an interrupt to wake up the device from Sleep. The PI flag is monitored via the Interrupt Service Routine (ISR) to see if the PIT period is elapsed. As soon as it wakes up, the PIT functionality gets disabled and the MCU continues to stay in Active mode until a new switch press event is detected.
<p align="center">
<img width=600 height=auto src="images/flowchart.png">
<br>Figure 2: Application Firmware Flowchart<br>
</p>
## Demo Operation
1. Make the hardware connections as shown in the hardware setup. Power up the Curiosity Nano board using a micro-USB cable.
2. Download the firmware available from the GitHub code example page.
3. Build the project using latest version of tools as mentioned in the Software Tools section and flash the generated file on the AVR128DB48 microcontroller.
4. Observe the device current consumption on the Data Visualizer Window in the Active mode.
<p align="center">
<img width=600 height=auto src="images/active_current.png">
<br>Figure 3: Active Current<br>
</p>
5. Press the on-board switch. It will switch the clock source to the external crystal.
<p align="center">
<img width=600 height=auto src="images/sleep_current.png">
<br>Figure 4: Sleep Current<br>
</p>
6. Observe the device current consumption in the Sleep mode.
7. Wait for 30s or any further switch press to determine the current consumption in Active mode.
## Conclusion
The power consumption of the microcontroller plays an important role in the battery powered applications. Hence, it is important to keep the microcontroller power consumption as minimum as possible for a longer battery life. This code example demonstrates low-power Sleep implementation using RTC and external crystal oscillator of AVR128DB48 microcontroller, as the external crystal oscillator provides a better overall performance compared to the internal oscillator and also minimizes the overall power consumptions of the microcontroller.
## Appendix
MPLAB Code Configurator (MCC) is a graphical programming environment that generates seamless, easy to understand C code that gives a head start to the project. It saves the designers time to initialize and configure all the modules, and to go through the data sheets. Using an instructive interface, it enables and configures all peripherals and functions specific to the application requirements.
@ -79,7 +104,7 @@ The following figure shows the system configuration setting in MCC tool.
<p align="center">
<img width=600 height=auto src="images/system_config.png">
<br>Figure 3: System Configuration<br>
<br>Figure 5: System Configuration<br>
</p>
### **SLPCTRL**
@ -91,7 +116,7 @@ Open **SLPCTRL** setup present under **System** dropdown menu in **Project Resou
<p align="center">
<img width=600 height=auto src="images/sleep_config.png">
<br>Figure 4: Sleep Control Configuration<br>
<br>Figure 6: Sleep Control Configuration<br>
</p>
### **RTC**
@ -105,7 +130,7 @@ Open **RTC** setup present under **Driver** dropdown menu in **Project Resources
<p align="center">
<img width=600 height=auto src="images/rtc_config.png">
<br>Figure 5: RTC Configuration<br>
<br>Figure 7: RTC Configuration<br>
</p>
## Pin Mapping
@ -113,12 +138,12 @@ The following images informs about the pin usage in the project.
<p align="center">
<img width=600 height=auto src="images/pin_config.png">
<br>Figure 6: Pin Mapping (List View)<br>
<br>Figure 8: Pin Mapping (List View)<br>
</p>
<p align="center">
<img width=600 height=auto src="images/pin_config1.png">
<br>Figure 7: Pin Mapping (Navigation View)<br>
<br>Figure 9: Pin Mapping (Navigation View)<br>
</p>
## Hardware Setup
@ -126,7 +151,7 @@ The following figure consists of AVR128DB48 Curiosity Nano Evaluation kit along
<p align="center">
<img width=600 height=auto src="images/setup.png">
<br>Figure 8: Hardware Setup<br>
<br>Figure 10: Hardware Setup<br>
</p>
## Data Visualizer
@ -135,51 +160,26 @@ The following figure consists of AVR128DB48 Curiosity Nano Evaluation kit along
<p align="center">
<img width=600 height=auto src="images/pwr_debug1.png">
<br>Figure 9: DGI Window<br>
<br>Figure 11: DGI Window<br>
</p>
* The available interfaces will be listed under Interfaces. To enable one, check the box next to the name. When it is enabled, the sources and sinks can be connected to other endpoints. The Gear button is used to configure the interface. See the interface-specific sections for an explanation of the configuration fields. In this case, Power.
<p align="center">
<img width=600 height=auto src="images/pwr_debug2.png">
<br>Figure 10: Interfaces and Settings<br>
<br>Figure 12: Interfaces and Settings<br>
</p>
* To start polling data from the interfaces, click the **Start** button. The Reset MCU check box will cause the MCU to be held in Reset during start. The Power Analysis module is made specifically for analyzing power consumption over time.
<p align="center">
<img width=600 height=auto src="images/pwr_debug3.png">
<br>Figure 11: Power Analysis Window<br>
<br>Figure 13: Power Analysis Window<br>
</p>
* Drag the Channel A Current and Channel A Voltage pins to their respective power analysis window, and then measure the current consumption of the microcontroller.
<p align="center">
<img width=600 height=auto src="images/pwr_debug4.png">
<br>Figure 12: Power Analysis Channel Settings<br>
</p>
## Demo Operation
1. Make the hardware connections as shown in the hardware setup. Power up the Curiosity Nano board using a micro-USB cable.
2. Download the firmware available from the GitHub code example page.
3. Build the project using latest version of tools as mentioned in the Software Tools section and flash the generated file on the AVR128DB48 microcontroller.
4. Observe the device current consumption on the Data Visualizer Window in the Active mode.
<p align="center">
<img width=600 height=auto src="images/active_current.png">
<br>Figure 13: Active Current<br>
</p>
5. Press the on-board switch. It will switch the clock source to the external crystal.
<p align="center">
<img width=600 height=auto src="images/sleep_current.png">
<br>Figure 14: Sleep Current<br>
</p>
6. Observe the device current consumption in the Sleep mode.
7. Wait for 30s or any further switch press to determine the current consumption in Active mode.
## Conclusion
The power consumption of the microcontroller plays an important role in the battery powered applications. Hence, it is important to keep the microcontroller power consumption as minimum as possible for a longer battery life. This code example demonstrates low-power Sleep implementation using RTC and external crystal oscillator of AVR128DB48 microcontroller, as the external crystal oscillator provides a better overall performance compared to the internal oscillator and also minimizes the overall power consumptions of the microcontroller.
<br>Figure 14: Power Analysis Channel Settings<br>
</p>

Plik binarny nie jest wyświetlany.

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 253 KiB

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 151 KiB

Plik binarny nie jest wyświetlany.

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 210 KiB

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 108 KiB