Microchip ATSAMD21E16 Handleiding


Lees hieronder de 📖 handleiding in het Nederlandse voor Microchip ATSAMD21E16 (44 pagina's) in de categorie Niet gecategoriseerd. Deze handleiding was nuttig voor 34 personen en werd door 2 gebruikers gemiddeld met 4.5 sterren beoordeeld

Pagina 1/44
TRAINING MANUAL
Single-slope PWM Implementation using SAM D21 TCC in
a Touch- based Application
AN- 9232
Prerequisites
Hardware Prerequisites
Atmel® SAM D21 Xplained Pro Evaluation Kit
Atmel KitQT1 Xplained Pro
USB Micro Cable (TypeA/ -B) Micro
Software Prerequisites
Atmel Studio 6.2 or higher
Atmel Software Framework 3.1 .0 or higher7
Atmel QTouch® Composer 5.3 or higher
Atmel QTouch Library 5.3 or higher
Documentation Prerequisites
Atmel- - - - - - - -42271 Introduction to QTouch Design Parameters using
SAM- - - - -D21 Xplained Pro_Training Manual_AN 7846 Training Manual
Estimated completion time: 60min.
Introduction
The goal of this hands on is to:-
Create a Touch proje using QTouch Project Builderct
Use QTouch Analyzer to test the project
Implement a PWM signal using the SAM D21 Timer/Counters for Control
peripheral the brightness (TCC) to drive of a LED
Modify the utton LED brightness in relation to the Touch Delta value of a B
sensor by updating the PWM duty cycle
42327 A 07/2014
AN- -9232 Single slope PWM Implementation using SAM D21 TCC in a Touch-based Application: 42327 2014A 07/
Page 442 of
Table of Contents
Prerequisites .....................................................................................1
Introduction .......................................................................................1
Icon Key Identifiers ...........................................................................3
1. Training Module Architecture .....................................................4
1.1 Atmel Studio Extension (.vsix) ............................................................. 4
1.2 Atmel Training Executable (.exe) ......................................................... 4
2. Introduction ................................................................................5
3. Assignment 1: Create a Touch project using QTouch Project
Builder ........................................................................................6
3.1 Project Creation ................................................................................... 6
3.2 Conclusion ......................................................................................... 18
4. Assignment 2: Use QTouch Analyzer to Test the Project ........ 19
4.1 Connect the Kit to QTouch Analyzer ................................................. 19
4.2 Test the Proximity Effect of the QTouch Application ......................... 23
4.3 Conclusion ......................................................................................... 24
5. Assignment 3: Implement a PWM Signal using the SAM D21
Timer/Counters for Control Application Peripheral (TCC) ........ 25
5.1 Introduction to Timer/Counters for Control Application (TCC) ........... 25
5.2 TCC Peripheral Initialization Using ASF Quick Start Guide. ............. 27
5.3 Conclusion ......................................................................................... 34
6. Assignment 4: Use QTouch Button to Control LED Brightness 35
6.1 Reading and using Button Touch Delta Value ................................... 35
6.2 Using PWM to Control LED Brightness ............................................. 37
6.3 Conclusion ......................................................................................... 41
7. Conclusion ............................................................................... 42
8. Revision History ....................................................................... 43
AN- -9232 Single slope PWM Implementation using SAM D21 TCC in a Touch-based Application: 42327 2014A 07/
Page 443 of
Icon Key Identifiers
Delivers contextual information about a specific topic.
Highlights useful tips and techniques.
Highlights objectives to be completed.
Highlights the expected result of an assignment step.
Indicates important information.
Highlights actions to be executed out of the target when
necessary.
AN- -9232 Single slope PWM Implementation using SAM D21 TCC in a Touch-based Application: 42327 2014A 07/
Page 444 of
1. Training Module Architecture
This training material can be retrieved through different Atmel deliveries:
As an Atmel Studio Extension ( file) usually found on the Atmel Gallery web site .vsix
( http://gallery.atmel.com/) or using the Atmel Studio Extension manager
As an Atmel Training Executable ( file) usually provided during Atmel Training sessions.exe
Depending on the delivery type, the different resources needed by this training material (hands-on
documentation, datasheets, application notes, software, and tools) will be found on different locations.
1.1 Atmel Studio Extension (.vsix)
Once the extension installed, you can open and create the different projects using New Example Project
from ASF..." in Atmel Studio.
The projects installed from an extension are usually under “Atmel Training >
Atmel Corp. Extension Name” .
There are different projects which can be available depending on the extension:
Hands-on Documentation: contains the documentation as required resources
Hands-on Assignment: contains the initial project that may be required to start
Hands-on Solution: contains the final application which is a solution for this hands- on
Each time a reference is made to some resources in the following pages, the user
must refer to the project folderHands-on Documentation .
1.2 Atmel Training Executable (.exe)
Depending where the executable has been installed, you will find the following architecture which is
composed by two main folders:
AN XXXX_Hands on- - : contains the initial project that may be required to start and a solution
Resources: contains required resources (datasheets, software, and tools…)
Unless a specific location is specified, each time a reference is made to some
resources in the following pages, the user must refer to this Resources folder.
AN- -9232 Single slope PWM Implementation using SAM D21 TCC in a Touch-based Application: 42327 2014A 07/
Page 445 of
2. Introduction
This hands-on will focus on the development of a simple Touch application that uses a Button sensor from the
Atmel QT1 Xplained Pro Self Capacitance extension board to modify the brightness of a LED.
The LED brightness is controlled using a PWM signal that is generated by one of the Atmel SAM D21
Timer/Counters for Control (TCC) peripherals.
The SAM D21 embeds three different 24 bit Timer/Counters for Control peripherals which provide extended -
functions compared to the standard Timer/Counters (TC):
Up to four compare channels with optional complementary outputs
Advanced waveform signal generation with dead time management
Deterministic fault protection, fast decay, and configurable dead time between complementary -
outputs
Dithering that increase resolution with up to five bits and reduce quantization error
The hands on will be divided in the following assignments:-
Create a new Touch project based on BUTTON 1 Touch sensor using QTouch lder from Project Bui
Atmel QTouch Composer:
Use QTouch Analyzer to provide graphical representation and demonstration of real time touch
data the . This will allow testing newly- . created Touch project
Implement a PWM signal using the TCC0 to control the LED8 brightnessperipheral
Atmel Software Framework TCC Quick Start Guide will be used to implement it (ASF)
easily
A Waveform Output pin (WO6) from the SAM D21 MCU will be used to output the PWM
signal directly to the LED8
Modify of the LED brightness in relation to the Touch Delta value BUTTON 1 by updating the PWM
duty cycle
Atmel QTouch library API will be used to get the delta value of BUTTON 1 sensor
BUTTON 1
LED8
AN- -9232 Single slope PWM Implementation using SAM D21 TCC in a Touch-based Application: 42327 2014A 07/
Page 446 of
3. Assignment 1: Create a Touch project using QTouch Project Builder
3.1 Project Creation
Create a new QTouch Project.
Open Atmel Studio 6.2
Click on the “QT” icon to open the QTouch Start Page :
QTouch StartPage is also accessible through the Tools menu:
Select “New QTouch UserBoard Project…”
Ensure “GCC QTouch Executable Project” is selected (default)*
AN- -9232 Single slope PWM Implementation using SAM D21 TCC in a Touch-based Application: 42327 2014A 07/
Page 447 of
Fill- in New Project fields according to following use cases:
Atmel Training Executable Case
Name: Hands On Assignment-
Location: “AN- - \ 9232_SAMD21 XPRO_QTouch_TCC assignments”
(relative path in the installation folder)ATMEL_TRAINING
Solution name: - Hands On Assignment
Click OK
Atmel Extension Case (downloaded from Atmel Gallery or Studio Extension Manager)
Name: Hands On Assignment-
Location: existing on Documentation Hands- solution path
Solution name: - Hands On Documentation
Click OK
AN- -9232 Single slope PWM Implementation using SAM D21 TCC in a Touch-based Application: 42327 2014A 07/
Page 448 of
The QTouch Project Builder wizard will guide through the steps involved in creating a QTouch projectnow .
Click “Next” in the Getting Started page (if shown):
The Kit design Page provides option to add, delete move QTouch Sensors such as button, wheel and an or
slider. also It provides options to setup physical and firmware properties of the board and sensors.
Add a button in the page by clicking on the “Button” icon, click “Add” and “NextKit Design
1
2
3
AN- -9232 Single slope PWM Implementation using SAM D21 TCC in a Touch-based Application: 42327 2014A 07/
Page 449 of
The technology Technology Selection Guide recommends which acquisition should be used based on the
number of sensors selected in Kit Design page and answers the below questionnairepreviously from .
We will consider for this hands on that our application hardware design exposed to moisture - is NOT
or water droplets or any specific sources of radiated noises
So, select “ ” as the answer to Question 1 . You will see that the proposed technology will No and 2
become QTouch ( i.e. Self Capacitance Technology):
For more information about designing the touch sensor, refer to Buttons, Sliders and
Wheels Touch Sensor Design Guide available at
www.atmel.com/images/doc10752.pdf.
Click “Next” in the Guide for Selecting Touch Technology page
AN- -9232 Single slope PWM Implementation using SAM D21 TCC in a Touch-based Application: 42327 2014A 07/
Page 10 44 of
Device Selection Page provides the option to view the number of QTouch sensors such as Button, Wheel and
Slider that was selected in the Kit Design Page.
Touch sensors can be based on two sub-technologies, QTouch/Self Capacitance and QMatrix/Mutual
Capacitance.
We can verify that has been correctly selected following our previous QTouch/ Self Capacitance
choice in the Guide for Selecting Touch Technology page
The device list displays device details such as Device Name, Variant, Application/Boot Memory, Data
Memory, EEPROM and supported technology. Data listing will vary based on device family, number of
selected sensors and technology as only devices supporting all choices made will be shown. Additionally user
has the option to search for a particular device.
Type “SAMD21” in the searc box to make a first filteringh
Select ATSAMD21J18A in the page and click “Next”. This is the device on the SAM Select Device
D21 Xplained Pro kit.
AN- -9232 Single slope PWM Implementation using SAM D21 TCC in a Touch-based Application: 42327 2014A 07/
Page 11 44 of
Self capacitance method uses a single sense electrode, denoted by a Y line.
Self capacitance touch button sensor is formed using a single Y line channel, while a touch rotor or slider
sensor can be formed using three Y line channels.
The Y-line numbering in the QT1 Xplained Pro User Guide does not correspond to
the Y-line numbering in the SAM D21 PTC module as the QT1 Xplained Pro is a
generic touch board (not dedicated to the SAM D21).
Flip the SAM D21 Xplained Pro and QT1 Xplained Pro boards and determine which SAM D21 I/O
pins that are connected to BUTTON 1
Look at next page to determine the right Y-line from QT1 Xplained PRO extension
board.
QT1
X plained PRO
SAM D21
Xplained PRO
AN- -9232 Single slope PWM Implementation using SAM D21 TCC in a Touch-based Application: 42327 2014A 07/
Page 12 44 of
Y- line for BUTTON 1 can be retrieved from the Atmel QT1 Xplained Pro User Guide
( http://www.atmel.com/Images/Atmel- - - - -42193 QT1 Xplained Pro_User Guide.pdf):
Table 3- 1. QT1 Xplained Pro SC Extension Header 1
Pin on EXT Function Description
1 ID Communication line to ID chip.
2 GND Ground
3 Y-Y_1 line 1 for Slider
4 Y-Y_2 line 2 for Slider
5 Y-Y_3 line 3 for Slider
6 Y-Y_4 line 4 for Wheel
7 LED_0 Slider, LED 0 (Yellow)
8 LED_1 Slider, LED 1 (Yellow)
9 Y-Y_5 line 5 for Wheel
10 Y-Y_6 line 6 for Wheel
11 Connected Not
12 Not Connected
13 Not Connected
14 Not Connected
15 LED_2 Slider, LED 2 (Yellow)
16 Y-Y_7 line 7 for Button 2
17 LED_3 Slider, LED 3 (Yellow)
18 Y-Y_8 line 8 for Button 1
19 Ground GND
20 VCC Target supply voltage
AN- -9232 Single slope PWM Implementation using SAM D21 TCC in a Touch-based Application: 42327 2014A 07/
Page 13 44 of
Use the page from QTouch Project Builder to select the Assign X-Y Line and Gain to the Channel
correct Y Line:
Y Line QT1 Xplained PRO
Y Line
SAM D21 Xplained PRO
Y Line – I/O
Y- – PA07 line Y_8 Y[5]
AN- -9232 Single slope PWM Implementation using SAM D21 TCC in a Touch-based Application: 42327 2014A 07/
Page 14 44 of
We also need to select on this page the for eachGain channel.
Gain setting -is applied on a per channel basis to allow superior sensitivity upon
contact. Recommended gain settings depend on the sensor design and touch panel
thickness.
The increase in the gain value is usually required by a thick front panel but also
depends on the sensor design (size of the sensor and coupling between X and Y for
mutual capacitance sensors).
Thicker front panels (3mm and more) can result in reduced sensitivity upon touch.
Likewise, smaller size sensors or sensors surrounded by ground layer or sensors
with ground on the bottom side typically require an increased gain setting.
In this application, we need to increase the sensor sensitivity to get the highest proximity effect
possible
As a consequence, set Gain to and click 32 “Next”.
AN- -9232 Single slope PWM Implementation using SAM D21 TCC in a Touch-based Application: 42327 2014A 07/
Page 15 44 of
Check the “Enable QDebug Interface” checkbox, which allows Live streaming of Touch data with
QTouch Analyzer
QDebug is the Touch data protocol used by QTouch Analyzer to communicate with
the SAM D21 through the Atmel nterface (Data Gateway I DGI).
The Atmel Embedded Debugger ( ) offers a Data Gateway Interface (EDBG DGI) for
streaming data to a host PC. This is meant as an aid in debugging and
demonstration of features in the application running on the target device. DGI
consists of multiple interfaces for data streaming. The supported interfaces are SPI
Interface, USART Interface, TWI Interface, and GPIO Interface.
SAM D21 G XPRO Kit Data ateway Interface supports SPI or I²C.
A 1 ssign the right port(s) and pins to the SPI interface, these can be found in the SAM D2 Xplained
Pro U G (ser uide on the pageAdvanced Options http://www.atmel.com/Images/Atmel- -42220
SAMD21-Xplained- -Pro_User Guide.pdf):
Table 3- 2. DGI Interface Connections when Using SPI
Pin on SAM D21 Function
PB31 SERCOM5 PAD[1] SPI SS (Slave select) (SAM D21 is Master)
PB16 SERCOM5 PAD[0] SPI MISO (Master In, Slave Out)
PB22 SERCOM5 PAD[2] SPI MOSI (Master Out, Slave In)
PB23 SERCOM5 PAD[3] SPI SCK (Clock Out)
AN- -9232 Single slope PWM Implementation using SAM D21 TCC in a Touch-based Application: 42327 2014A 07/
Page 16 44 of
The following table extracted from the QTouch Library PTC User Guide (http://www.atmel.com/Images/Atmel-
42195 Qtouch Library Peripher Touch Controller_User Guide.pdf- - - al- - - ), indicates the expected Resting Signal
value (also called for a given combination of gain setting and filter level setting.Reference)
Expected Resting Signal
Value for FILTER LEVEL
and GAIN Combination GAIN_1=0 GAIN_2=1 GAIN_4=2 GAIN_8=3 GAIN_16=4 GAIN_32=5
FILER_LEVEL_1 = 0
512 512 512 512 512 512
FILER_LEVEL_2 = 1
512 1024 1024 1024 1024 1024
FILER_LEVEL_4 = 2
512 1024 2048 2048 2048 2048
FILER_LEVEL_8 = 3
512 1024 2048 4096 4096 4096
FILER_LEVEL_16 = 4
512 1024 2048 4096 8192 8192
FILER_LEVEL_32 = 5
512 1024 2048 4096 8192 16384
FILER_LEVEL_64 = 6
512 1024 2048 4096 8192 16384
By increasing both the Gain and the Filter Level, we will increase the Reference value and so scale up the
Touch Delta value will allow improving the proximity effect, which .
(Touch) Delta represents the difference between the Signal and the Reference.
On the pdate Filter Level to on the Advanced Options page, u 64:
AN- -9232 Single slope PWM Implementation using SAM D21 TCC in a Touch-based Application: 42327 2014A 07/
Page 17 44 of
Review the Summary page which provides a summary of the settings provided by the previous set
of wizard pages. Then, click on Finish and wait for your Touch project to be generated.
AN- -9232 Single slope PWM Implementation using SAM D21 TCC in a Touch-based Application: 42327 2014A 07/
Page 18 44 of
You have created a T B Touch Project with a Self Capacitance technology ouch utton.
3.2 Conclusion
In the first assignment, you have learnt:
How to create a Touch Project using QTouch Composer Project Builder
How easy it is to use QTouch Composer to design a Touch project on the Atmel SAM D21 MCUs
AN- -9232 Single slope PWM Implementation using SAM D21 TCC in a Touch-based Application: 42327 2014A 07/
Page 19 44 of
4. Assignment 2: Use QTouch Analyzer to T the P est roject
4.1 Conne to ct the Kit QTouch Analyzer
Build t Q . he Touch project and Program the SAM D21 Xplained Pro
Connect the QT1 Xplained Pro Capacitance board to the SAM D21 Xplained Pro board:Self
Connect the SAM D21 Xplained Pro to your PCboard using DEBUG USB connector
Build the solution and ensure you get no errors:
Program the application by clicking on the Start Without Debugging icon:
DEBUG USB
AN- -9232 Single slope PWM Implementation using SAM D21 TCC in a Touch-based Application: 42327 2014A 07/
Page 20 44 of
You will be asked the first time to select your debug tool:
Select your EDBG and SWD (Serial Wire Debug) as Interface:
Set SWD clock to 8MHz to speed up programming:
Click again on the Start Without Debugging icon:
You may be asked to upgrade your EDBG firmware. If so, click on Upgrade:
Upgrade operation may take a few minutes, please wait for the operation to
complete.
Your QTouch project is now updated and programmed on the SAM D21 Xplained
Pro.
AN- -9232 Single slope PWM Implementation using SAM D21 TCC in a Touch-based Application: 42327 2014A 07/
Page 21 44 of
Connect your kit to QTouch Analyzer.
Press RESET button on the SAM D21 Xplained Pro
Launch QTouch Analyzer by clicking on the following icon:
QTouch Analyzer is also accessible through the Tools menu:
A kit named QD _DGI will be listed in the combo box.EBUG
Select the kit and click on Connect:
DGI settings dialog box will be displayed as shown in the figure, click OK:
AN- -9232 Single slope PWM Implementation using SAM D21 TCC in a Touch-based Application: 42327 2014A 07/
Page 22 44 of
The Virtual kit will be displayed, which shows it has been correctly connected:
Click on Start Reading:
QTouch Analyzer is now connected to your kit and displays both the sensor signal
and reference values.
C lick on Stop Reading to prevent QTouch Analyzer from collecting touch data over a
long period as this might slow down the computer.
AN- -9232 Single slope PWM Implementation using SAM D21 TCC in a Touch-based Application: 42327 2014A 07/
Page 23 44 of
4.2 Test the Proximity Effect of the QTouch Application
C . heck proximity effect
Click on checkbox “Check to enable user scale” and set Y scale from 0 to 50:
Click on Start Reading:
Unselect Signals and References and Deltas in the Trace View
Select Deltas and Detect Threshold in the Trace View
AN- -9232 Single slope PWM Implementation using SAM D21 TCC in a Touch-based Application: 42327 2014A 07/
Page 24 44 of
Approach BUTTON 1 on your kit, which is displayed as Button0 on QTouch Analyzer and check
that a detect touch can occur BEFORE touching the sensor (i.e. the sensor Touch Delta value
becomes higher than Detect Threshold)its .
You can also check signal, reference and delta values as well as Touch Button state
by using the Tabular View instead of the Trace View:
You may in some cases, observe a detect touch even without approaching the finger.
This is due to the high gain . value which has been configured for that sensor The
highest the gain is, the highest sensitivity the sensor is.
The proximity effect of the Touch project behaves . as expected
4.3 Conclusion
In this assignment, you have learnt:
How to use QTouch Analyzer to test a Touch application
Touch
Detected
AN- -9232 Single slope PWM Implementation using SAM D21 TCC in a Touch-based Application: 42327 2014A 07/
Page 25 44 of
5. Assignment 3: Implement a PWM Signal using the SAM D21 Timer/Counters
for Control Application Peripheral (TCC)
In this assignment, a Pulse Width M- odulation (PWM) signal will be generated using the SAM D21
Timer/Counters for Control Application (TCC) QT1 Xplained Pro extension boardto the oflight LED8 :
5.1 Introduction to Timer/Counters for Control Application (TCC)
T - he TCC will be used in Single Slope PWM mode to generate the required PWM signal and output it on a
dedicated Waveform Output pin (WO[x]).
For single-slope PWM generation , the period time is controlled by , while the mode the Period register (PER)
Compare/Capture registers (CCx) control the duty cycle of the waveform.
When up-counting pin (default configuration), WO[x] is:
S ) s et at start or compare match between the counter (COUNT and period (PER) registers’ value
C ) ) leared on compare match between the counter (COUNT and Compare/Capture (CCx registers’
values
LED8
BUTTON 1
AN- -9232 Single slope PWM Implementation using SAM D21 TCC in a Touch-based Application: 42327 2014A 07/
Page 26 44 of
Determine which Waveform Output pin . to use
By flipping the boards, you can check that the LED8 of the QT1 Xplained Pro extension board is
connected to the SAM D21 Xplained Pro board pin PB12:
By looking at the SAM D21 product datasheet, you can verify that thnow is is the Waveform Output
pin 6 [6] (WO ) from TCC0 which is multiplexed with PB12
Table 5 Function Multiplexing (Continued)- 1. PORT
Pin I/O Pin Supply A B C D E F G H Type
SAMD21E
SAMD21G
SAMD21J -EIC REF ADC AC PTC DAC SERCOM SERCOM ALT
TC/TCC TCC COM AC/GCLK
PB10 19 23 VDDIO EXTINT[10] SERCOM4
/PAD[2]
TC5/WO[0] TCC0/
WO[4]
I2S/
MCK[1]
GCLK_IO[4]
PB11 20 24 VDDIO EXTINT[11] SERCOM4
/PAD[3]
TC5/WO[1] TCC0/
WO[5]
I2S/
SCK[1}
GCLK_IO[5]
PB12 I25 VDDIO 2C EXTINT[12] X[12] SERCOM4/
PAD[0]
TC4/WO[0] TCC0/
WO[6]
I2S/
FS[1]
GCLK_IO[6]
SAM D21 Product Datasheet can be retrieved at the following link:
http://www.atmel.com/Images/Atmel- - -42181 SAM D21_Datasheet.pdf.
WO[6] pin must d . be use to output the PWM signal directly to LED8 using TCC0
QT1
X plained PRO
SAM D21
Xplained PRO
AN- -9232 Single slope PWM Implementation using SAM D21 TCC in a Touch-based Application: 42327 2014A 07/
Page 27 44 of
5.2 Peripheral TCC Initialization Using ASF Quick Start Guide
The drivers in ASF have quick start guides as part of their API documentation.
Quick Start guides show and explain, in a step-by-step process, the code and actions needed to set up and
use a driver in one or more use cases.
Once a driver such as TCC is added using the ASF Wizard, its Quick Start Guide becomes available in the
ASF Explorer view.
To get started on the ASF API documentation as the Quick Start Guides, please go
to: http://asf.atmel.com/docs/latest/get_started.html.
Add TCC Support using ASF Wizard.
Click on the ASF Wizard icon or r on the Hands on Assignment pright click - oject > ASF Wizard
From latest ASF version available, s the following component and add it to the Selected elect
Modules (Add >> button):
TCC – Timer Counter for Control Applications (driver) polled
In this application, TCC polled driver version can be used as no interrupt(s)
management is required to generate the PWM signal on the waveform output WO[x]
pin.
Click on Apply button
AN- -9232 Single slope PWM Implementation using SAM D21 TCC in a Touch-based Application: 42327 2014A 07/
Page 28 44 of
Click on Solution Explorer tab and check that the TCC driver has been successfully added as
shown below:
TCC driver is added to the project.


Product specificaties

Merk: Microchip
Categorie: Niet gecategoriseerd
Model: ATSAMD21E16

Heb je hulp nodig?

Als je hulp nodig hebt met Microchip ATSAMD21E16 stel dan hieronder een vraag en andere gebruikers zullen je antwoorden




Handleiding Niet gecategoriseerd Microchip

Handleiding Niet gecategoriseerd

Nieuwste handleidingen voor Niet gecategoriseerd