Link Search Menu Expand Document

AC Sleepwalking Application built with GCC Toolchain on SAM D21 Xplained Pro Kit

Download


Description:

This application demonstrates how to use the AC (Analog Comparators) Peripheral library to perform a single-shot conversion when the peripheral is triggered by the RTC (Real-Time Counter) compare event. The generation of a trigger and compare operation is done while the CPU is in the standby sleep mode. The AC generates the interrupt at the end of the comparison which wakes the CPU.

The application demonstrates to build an MPLAB Harmony v3 project with ARM GNU Toolchain in MPLABX IDE. The page demonstrates configuring, building, and running an MPLAB Harmony v3 peripheral library (PLIB) based application with the ARM GCC toolchain developed on the SAM D21 Xplained Pro Evaluation Kit.

Modules/Technology Used:

  • Peripheral Modules
    • AC
    • PORTS
    • RTC
    • PM (Power Manager)
    • SERCOM (USART)

Hardware Used:

Software/Tools Used:

This project has been verified to work with the following versions of software tools:

Refer Project Manifest present in harmony-manifest-success.yml under the project folder firmware/src/config/sam_d21_xpro

  • Refer the Release Notes to know the MPLAB X IDE and MCC Plugin version. Alternatively, Click Here.
  • Any Serial Terminal application like Tera Term terminal application.

Because Microchip regularly update tools, occasionally issue(s) could be discovered while using the newer versions of the tools. If the project doesn’t seem to work and version incompatibility is suspected, It is recommended to double-check and use the same versions that the project was tested with. To download original version of MPLAB Harmony v3 packages, refer to document How to Use the MPLAB Harmony v3 Project Manifest Feature

Setting up SAM D21 Xplained Pro Evaluation Kit:

  • Connect a voltage below VDD to pin 17 of the EXT1 connector
  • Connect the Debug USB port on the board to the computer using a micro USB cable

Prerequisite:

Configure the project to use ARM GCC Toolchain:

This can be done with two methods, either automatically or manually.

  1. Automatic Detection: If Atmel Studio is installed in PC, By default, MPLAB X IDE detects the ARM GCC toolchain (installed as a part of Atmel Studio) and shows it in the MPLAB X IDE’s Project properties. Since the ARM GCC toolchain is already available, switch to the ARM GCC toolchain from the project properties.
  2. Manual: If Atmel Studio is not installed, install the ARM GCC toolchain manually. Go to MPLAB X IDE -> Tools -> Options -> Embedded -> Build Tools -> Add -> give the base directory -> Enter the path of “xx/xxx/toolchain/arm/arm-gnu-toolchain\bin”. Save it.
    • Now, select the ARM GCC toolchain in the project properties. Select the Project -> Right Click -> Properties -> select the ARM GCC toolchain in compiler options and save.

Programming hex file:

The pre-built hex file can be programmed by following the below steps

Steps to program the hex file:

  • Open MPLAB X IDE
  • Close all existing projects in IDE, if any project is opened.
  • Go to File -> Import -> Hex/ELF File
  • In the “Import Image File” window, Step 1 - Create Prebuilt Project, click the “Browse” button to select the prebuilt hex file.
  • Select Device has “ATSAMD21J18A”
  • Ensure the proper tool is selected under “Hardware Tool”
  • Click on “Next” button
  • In the “Import Image File” window, Step 2 - Select Project Name and Folder, select appropriate project name and folder
  • Click on “Finish” button
  • In MPLAB X IDE, click on “Make and Program Device” Button. The device gets programmed in sometime.
  • Follow the steps in “Running the Demo” section below

Programming/Debugging Application Project:

  • Open the project (sam_d21_xpro\samd21_ac_sleepwalk_singleshot_gcc\firmware\sam_d21_xpro.X) in MPLAB X IDE
  • Ensure “SAM D21 Xplained Pro” is selected as hardware tool to program/debug the application
  • Build the code and program the device by clicking on the “Make and Program Device” button in MPLAB X IDE tool bar
  • Follow the steps in “Running the Demo” section below

Running the Demo:

  • Perform Prerequisite, Configure the project to use ARM GCC Toolchain and Setting up SAM D21 Xplained Pro Evaluation Kit steps mentioned above, if not done already.
  • Open the Tera Term terminal application on your PC (from the Windows® Start menu by pressing the Start button)
  • Connect to the EDBG Virtual COM port and configure the baud rate to 115200
  • Build and Program the application using the MPLAB X IDE.
  • The console displays the message stating whether voltage at PA04 is lower or greater than the internal bandgap voltage (1.1 V)
  • LED0 toggles when comparison is done.

Comments:

Revision:

  • v1.6.0 Regenerated and tested the application
  • v1.5.0 Removed MHC support, Regenerated and tested application.
  • v1.4.0 Added MCC support, Regenerated and tested application.
  • v1.3.0 regenerated and tested demo application
  • v1.2.0 regenerated and tested demo application
  • v1.1.0 released demo application


Copyright © 2020 Microchip Technology.