Transcript
APPLICATION NOTE Atmel AT04150: QTouch with SAM4L Training Guide Atmel QTouch Features • •
Knowledge level: Intermediate Hardware requirements:
• • • • • •
•
Software requirements:
• • • •
•
PC SAM4L-EK kit QT™600 USB Bridge Interface Card Micro-USB Cable – 1 No. Mini-USB Cable – 1 No. Connecting wires – 5 Nos. Atmel® Studio 6.1.2562 or later QTouch® Composer Extension 5.1.1048 (or later) for Atmel Studio 6.1 QTouch Library 5.1.1017 (or later) for Atmel Studio 6.1 ASF 3.8.1 (or later) for Atmel Studio 6.1
Estimated time to complete the task: 3 hours
42180A−QTOUCH−09/2013
Table of Contents 1. Introduction .......................................................................................... 3 1.1 Overview of SAM4L-EK Kit ............................................................................... 3 2. Task 1 – Connect the Kit and Run a Test Application.......................... 4 2.1 Programming Output File Using Atmel Studio 6.1 ............................................. 4 3. Task 2 – Creating a Touch Project....................................................... 7 3.1 Creating a Touch Project by Using the QTouch Composer .............................. 7 3.2 Add the LED Code .......................................................................................... 10 3.3 Program the Output File .................................................................................. 11 4. Task 3 – Autonomous Touch ............................................................. 12 4.1 Opening Project .............................................................................................. 12 4.2 Configure Autonomous Touch Sensor Parameters ......................................... 12 4.3 Enable Autonomous Touch ............................................................................. 14 4.4 Program the Output File .................................................................................. 15 5. Task 4 – User Scenario ..................................................................... 16 5.1 Opening Project .............................................................................................. 16 5.2 Enabling Autonomous Touch Sensing ............................................................ 16 5.3 Program the Output File .................................................................................. 18 6. Task 5 – Reducing Power .................................................................. 19 6.1 System Clock Frequency ................................................................................ 19 6.2 Enabling Sleep and Adjusting the Sleep Period .............................................. 19 6.3 Disable CATB Clock before Going to Sleep .................................................... 20 7. Task 6 – Including QDebug Interface ................................................ 21 7.1 Opening Project .............................................................................................. 21 7.2 Enabling QDebug ............................................................................................ 21 7.3 Connecting QT600 and SAM4L-EK Board ...................................................... 22 7.4 Program the Output File .................................................................................. 22 8. Revision History ................................................................................. 23
Atmel AT04150: QTouch with SAM4L Training Guide [APPLICATION NOTE] 42180A−QTOUCH−09/2013
2
1.
Introduction The purpose of this document is to get familiar with creating a QTouch project for SAM4L device using QTouch composer and to test the same on SAM4L-EK kit. This document provides the steps to enable autonomous touch sensing. Additional tasks have been included to demonstrate on how to reduce power consumption for QTouch project on SAM4L device.
1.1
Overview of SAM4L-EK Kit The SAM4L device is based on Cortex®-M4 ARM® architecture targeted for low power applications. In order to show case the low power capabilities, the SAM4L-EK kit has a dedicated OLED display to plot the current consumption of the SAM4L device. The SAM4L-EK kit is designed to showcase the capabilities of SAM4L device targeted for applications requiring LCD control, USB communication and touch. The kit is built based on SAM4LC4C device. Figure 1-1 provides an image of the SAM4L-EK kit. Figure 1-1. SAM4L-EK Kit Feature Set.
Atmel AT04150: QTouch with SAM4L Training Guide [APPLICATION NOTE] 42180A−QTOUCH−09/2013
3
2.
Task 1 – Connect the Kit and Run a Test Application The objective of this task is to ensure that kit is working as intended. No code writing is required for this task. You can program the qt_sam4l_1b_1s.hex file present in the following location. ..\Exercise\Task1\ The J-Link interface is included as part of the SAM4L-EK kit. So, no separate programming tool is required.
2.1
Programming Output File Using Atmel Studio 6.1 .Hex or .elf file can be programmed to the MCU by following steps provided.
¾ Open Atmel Studio 6.1 by clicking the Atmel Studio 6.1 icon in the desktop. ¾ Open “Device Programming” window by selecting Tools->Device Programming as shown in Figure 2-1. Figure 2-1. Open Programming Window.
¾ Connect the SAM4L-EK kit to PC using micro-USB cable. The USB cable should be connected to J1 connector of SAM4L-EK. ¾ Select the tool as “J-Link”, device as “ATSAM4LC4C” and interface as “SWD” and click on Apply button as shown in Figure 2-2.
Atmel AT04150: QTouch with SAM4L Training Guide [APPLICATION NOTE] 42180A−QTOUCH−09/2013
4
Figure 2-2. Select Tool, Device, and Interface.
¾ Click on the Read buttons and ensure that the device signature is read properly and the target voltage is set to 3.3V as shown in Figure 2-3. Figure 2-3. Read Signature and Target Voltage.
Atmel AT04150: QTouch with SAM4L Training Guide [APPLICATION NOTE] 42180A−QTOUCH−09/2013
5
¾ Click on the Memories option available to the left and browse to the .hex file and click on the Program button as shown in Figure 2-4. Figure 2-4. Select .hex File and Program.
¾ Close the Device Programming window after the programming of the device is completed. ¾ Power OFF/ON the board. ¾ LED0 is expected to glow if the button or slider is touched.
Atmel AT04150: QTouch with SAM4L Training Guide [APPLICATION NOTE] 42180A−QTOUCH−09/2013
6
3.
Task 2 – Creating a Touch Project The Objective of this task is to create a touch project with one button and one slider sensors for SAM4L-EK kit using QTouch Composer. The LED should glow when the sensors are touched. ¾ Create a touch project for SAM4L using QTouch composer for the following configuration: Total Number of sensors: One button, one slider Button Sense pin: PB04 (SENSE24) Slider Sense Pins: SP_PA04 (SENSE0), SP_PA05 (SENSE1), SP_PB02 (SENSE23) Discharge pin: PB03 QDebug: Disable
Note:
The following section provides the steps to create a touch project using QTouch composer. Refer to “Atmel AT03075: Getting Started with SAM4L using QTouch Composer” application note for more details.
3.1
Creating a Touch Project by Using the QTouch Composer ¾ Create a new project by clicking File->New->Project as shown in Figure 3-1. Figure 3-1. Open New Project Window.
¾ Select “GCC C QTouch Executable Project” from the installed template and provide the project name and location as shown in Figure 3-2.
Atmel AT04150: QTouch with SAM4L Training Guide [APPLICATION NOTE] 42180A−QTOUCH−09/2013
7
Figure 3-2. New Project Window.
¾ The QTouch Project Builder window opens with default Getting Started page. Click Next on Getting Started page. ¾ Next page is the Kit Design page. Click on Button icon and add ‘1’ button as shown in Figure 3-3. Figure 3-3. QTouch Composer – Kit Design Page.
¾ Similarly, add one slider by clicking the Slider icon. Click Next. ¾ Guide for Selecting Touch Technology window will open. By default QTouch is selected, click Next.
Atmel AT04150: QTouch with SAM4L Training Guide [APPLICATION NOTE] 42180A−QTOUCH−09/2013
8
¾ Next page is the Select Device page. Select Device Family as SAM4L and ATSAM4LC4C as the device shown in Figure 3-4. Figure 3-4. QTouch Composer – Select Device Page.
¾ In the PortPin Pair Configuration window, select port pin for sensing and discharge as shown in Figure 3-5 and click Next. Figure 3-5. QTouch Composer – Assign Port Pin Pair Page.
Atmel AT04150: QTouch with SAM4L Training Guide [APPLICATION NOTE] 42180A−QTOUCH−09/2013
9
¾ Next window is the Advance Options page. No need to change anything in that window. Click Next. ¾ In the summary page click Finish. Preparing QTouch Project progress bar will be popped up as shown below.
¾ Now the touch project is created as per the required configuration.
3.2
Add the LED Code In the SAM4L-EK kit LED0 is connected to PC10 pin. The LED0 will be used to show the touch status. The variable “touch_qt_time.measurement_done_touch” is set to 1 by the QTouch library if touch measurement is completed for all the enabled sensors. So, updated sensor state will be available only if “touch_qt_time.measurement_done_touch” is set to 1. In touch.c file, “touch_qt_time.measurment_done_touch” is cleared if it is set, in touch_sensor_measure(). Comment the clearing part so that it can be used in main.c file.
¾ Configure PC10 as output-low after calling board_init() in main.c file as follows. Enable the GPIO peripheral clock before configuring the pin.
¾ In the main while(1) loop, add the following code after the touch_sensors_measure() call. This will check whether touch measurement is done or not and based on the touch sensor state, PC10 pin will be set to HIGH or LOW.
¾ Comment the “touch_qt_time.measurement_done_touch = 0u;” statement in touch.c file.
Atmel AT04150: QTouch with SAM4L Training Guide [APPLICATION NOTE] 42180A−QTOUCH−09/2013
10
3.3
Program the Output File ¾ Build the project and program the .hex to SAM4L-EK kit in Atmel Studio 6.1. In the programming window of Atmel Studio 6.1, select J-link as the tool, ATSAM4LC4C as the device, and SWD as the interface, and program the .hex file generated. Close the programming window and power-cycle the SAM4L-EK kit. ¾ LED0 is expected to glow if the button or slider is touched.
Atmel AT04150: QTouch with SAM4L Training Guide [APPLICATION NOTE] 42180A−QTOUCH−09/2013
11
4.
Task 3 – Autonomous Touch The objective of this task is to perform touch measurement without CPU intervention and to wake up the CPU from sleep when the autonomous sensor electrode is touched / untouched. On wakeup, CPU should switch ON/OFF a LED based on the touch status. In this task the SleepWalking feature of the SAM4L device will be used in order to perform Autonomous touch sensing.
4.1
Opening Project For this task, user needs to open the project available in location “../Exercise/Task3/”. This project is created using QTouch Composer for SAM4L with one button and one slider. Since this is QTouch Composer created project, remove the unwanted sections. ¾ Open the project in Atmel Studio 6.1. Comment “touch_sensor_init()” and “touch_sensors_measure()” function calls in main.c file.
4.2
Configure Autonomous Touch Sensor Parameters The touch.c and touch.h files created by QTouch Composer have the required APIs and parameters for autonomous touch sensing. This task uses the same APIs and parameters.
DEF_TOUCH_AUTONOMOUS_QTOUCH The macro “DEF_TOUCH_AUTONOMOUS_QTOUCH” in touch.h file tells whether the autonomous touch sensing is performed by the application or not. It needs to be set to 1 in order to use the APIs related to autonomous touch. ¾ Define the macro “DEF_TOUCH_AUTONOMOUS_QTOUCH” as 1 in touch.h file. AT_SP_SELECTED The CATB module can perform touch measurement on only one sensor without CPU intervention (Autonomous touch). The pin to which the sensor is connected needs to be specified in “AT_SP_SELECTED” macro. In SAM4L-EK board, the button is connected to PB04 (SENSE24). ¾ Define the macro “AT_SP_SELECTED” as “SP_PB04”. SP_PB04 is the member of enum created by QTouch library for each sense pin. Similarly the discharge pin is defined in “AT_DISCHARGE_PIN_SELECTED” macro. Define the same as “DIS_PB03”. AT_CLOCK_SEL The CATB module is capable of running on both GCLK and the internal RC80M clock. The CATB module source clock needs to be configured in the control register. The clock source is specified by “AT_CLOCK_SEL” macro. AT_CLOCK_SEL
Description
0
CATB module uses internal RC80M for touch measurement and timing reference
1
CATB module uses GCLK for touch measurement and timing reference
¾ Configure AT_CLOCK_SEL value for using RC80M internal clock.
Atmel AT04150: QTouch with SAM4L Training Guide [APPLICATION NOTE] 42180A−QTOUCH−09/2013
12
AT_DISCHARGET The touch sensors are charged to a pre-defined voltage and the charge stored in the sensors is discharged through discharge pin. The CATB module monitors the time taken for discharging. The parameter “AT_DISCHARGET” decides how much time the CATB module should wait for discharge. The discharge time will be = (1/CATB ACQ clock) * (AT_DISCHARGET). ¾ Configure AT_DISCHARGET in order to wait for 12.5µsec for discharging. 12.5µsec is sufficient for discharging the charge stored in the button sensor available in SAM4L-EK kit. AT_CHARGET As discussed earlier, the touch sensors are charged to a pre-defined voltage before discharging. The time required to charge the sensor electrode to a pre-defined voltage is specified by AT_CHARGET. The CATB module will wait for 2^(AT_CHARGET) of acquisition clock for charging the sensor electrode. ¾ Configure AT_CHARGET as 0. 1 clock cycle time is sufficient for charging the sensor electrode. AT_REPEAT In one touch measurement, touch acquisition is performed for AT_REPEAT+1. If AT_REPEAT is configured to non-zero value, then touch acquisition will be performed for more than one time which will increase the sensitivity. This feature will be useful for proximity sensing application. For normal finger touch AT_REPEAT can be configured to 0. Time gap between two acquisitions depends on the AT_DISCHARGET. ¾ Configure AT_REPEAT as 0. AT_SPREAD Based on the AT_CHARGET and AT_DISCHARGET, the touch acquisition looks like a series of pulses sent towards the sensor pins. The energy radiated due to the pulses will be high on the frequency of the pulse applied. To avoid that, CATB module provides option to enable spread operation, which adjusts the discharge time, between two acquisitions in order to spread the energy radiated on a single frequency. Non-zero value of AT_SPREAD will enable spreading operation and the range of spread depends on the value of AT_SPREAD. ¾ Configure AT_SPREAD as 0. AT_THRESHOLD AT_THRESHOLD is same as detect threshold. If delta between reference and signal is more than AT_THRESHOLD, then the CATB module will declare the same as touch detection and can issue an interrupt to CPU. ¾ Configure AT_THRESHOLD as 15. AT_DI Due to spurious noise, some time the delta value can exceed AT_THRESHOLD. In order to avoid such instances, the CATB module will check multiple times before declaring the touch detection. The number of times depends on AT_DI. ¾ Configure AT_DI as 3.
Atmel AT04150: QTouch with SAM4L Training Guide [APPLICATION NOTE] 42180A−QTOUCH−09/2013
13
AT_ESAMPLES Autonomous touch measurement is triggered when a peripheral event occurred. Number of touch measurement per event trigger depends on AT_ESAMPLES. Total number of touch measurement is AT_ESAMPLES+1. So, in order to reduce the touch response time, the user can configure the AT_ESAMEPLES in such a way that the total number of samples taken per event trigger is equal to the DI. Increasing AT_ESAMPLES increases the acquisition time during SleepWalking and will result in increased power consumption. ¾ Configure AT_ESAMPLES as 2. AT_TIDLE In CATB, reference values are referred as IDLE, signal values as RAW and delta values as LEVEL. In order to have zero LEVEL value, filtering is applied on RAW value and corrected on the IDLE value. The rate at which the IDLE value should be adjusted in order to have LEVEL as zero is depends on AT_TIDLE. ¾ Configure the AT_TIDLE value as 4. AT_TLEVEL In addition to filtering of RAW signal value, the LEVEL value is averaged in order to reduce the effect of noise further. The AT_TLEVEL should be bigger value so that the touch is not averaged out. ¾ Configure AT_TLEVEL as 2048.
4.3
Enable Autonomous Touch The API “touch_autonomous_sensor_enable()” provided by QTouch library enables the Autonomous touch by configuring the CATB module based on the settings defined in touch.h file. The QTouch library configures the CATB module to perform touch acquisition on an event by setting ETRIG bit in CATB control register. The application need to enable an event and map the same to CATB module using Peripheral Event Control (PEVC) module. In this task AST periodic event will be used for CATB. The QTouch composer created project configures the AST to issue periodic interrupt. The channel multiplexer register (CHMX) of PEVC is used to map the event user and event generator. The user is nothing but CATB and generator is AST. “Event shaper” module available in the PEVC needs to be enabled in order to synchronize the events and to enable CLK_PEVC in deeper sleep modes. The channel can be enabled or disabled by using the channel enable register of PEVC. ¾ After the configure_ast() function call, disable the AST periodic interrupt and enable AST periodic event as shown below.
Since PEVC is used to map the AST event for CATB, enable PEVC peripheral clock using sysclk_enable_peripheral_clock() function similar to CATB and PDCA. Configure the PEVC as shown below, which maps the AST event to CATB and enables the channel.
Atmel AT04150: QTouch with SAM4L Training Guide [APPLICATION NOTE] 42180A−QTOUCH−09/2013
14
¾ Call touch_autonomous_sensor_enable() to enable autonomous touch sensing. The autonomous touch sensing is currently enabled. In order to view the touch status let us use LED0. The QTouch library provides a call back when the CATB module triggers an interrupt. The call back function is touch_at_status_change_interrupt_callback(). In touch.c file, this function is defined and the touch status is updated in “autonomous_qtouch_in_touch” variable. The variable type is volatile int8_t. Enable the CATB interrupt in NVIC control register and set the priority as follows.
¾ In order to use that variable in main.c file, extern the same to main.c file. In while(1) loop, check the flag status. If it is ‘1’ then sensor is in detect state and if it is ‘0’ the sensor is not in detect state. Refer task 1 for LED code.
4.4
Program the Output File ¾ Build the project and program the same to SAM4L-EK kit using Atmel Studio 6. ¾ LED0 is expected to glow if the button is touched.
Atmel AT04150: QTouch with SAM4L Training Guide [APPLICATION NOTE] 42180A−QTOUCH−09/2013
15
5.
Task 4 – User Scenario The objective of this task is to enable autonomous touch sensing if the touch sensors are not touched for a specified time. CATB module performs touch sensing autonomously and wake up the CPU upon touch detection. Upon CPU wakeup the normal touch sensing has to be enabled in order to perform periodic touch measurement. This will help in reducing the power consumed by the application. Use the project available in folder Exercise\Task4 for this Task.
5.1
Opening Project For this task, user needs to open the project available in location “../Exercise/Task4/”. This project is created using QTouch Composer for SAM4L with one button and one slider similar to that of Task 2 (see Chapter 3). Additionally LED code is required to indicate if button or slider is in “detect” state. ¾ Open the project in Atmel Studio 6.1.
5.2
Enabling Autonomous Touch Sensing A software timer is required in order to check whether specified time is expired from the previous touch. Considering 4sec timeout period, the value in touch_sensor_idle_time should be more than 125 to enable autonomous touch sensing. In the project the macro “SENSOR_TOUCH_TIMEOUT” is defined to 125.
Note:
Calling touch_sensor_deinit() without considering "touch_qt_time.measurement_done_touch" might lead to undefined state. It is recommended to call the function "touch_sensors_deinit()" only if the "touch_qt_time.measurement_done_touch" is '1'. This will ensure that the QTouch library and PDCA is in defined state. Similarly, the sensor state provided by the GET_QT_SENSOR_STATE() macro, is also valid only if "touch_qt_time.measurement_done_touch" is set to '1'. This check is already included in the project that is used for this task. ¾ Enable and configure the autonomous touch sensing parameters as mentioned in Section 5.2. Create a global variable “uint16_t touch_sensor_idle_time” in main.c file. Increment this variable by ‘1’ in that function. With this a software timer is achieved with resolution of 32msec. The AST interrupt call back function, ast_per_callback(), is called when AST interrupt occurs. Create an “if-condition” for checking whether touch_sensor_idle_time is greater than “SENSOR_TOUCH_TIMEOUT” inside “touch_qt_time.measurement_done_touch” if condition. If the touch_sensor_idle_time is greater than SENSOR_TOUCH_TIMEOUT, then disable interrupt by calling “Disable_global_interrupt()” and disable periodic touch measurement by calling touch_sensors_deinit().
Disable AST periodic interrupt and enable AST periodic event similar to Task 3 (see Chapter 4). Configure the AST periodic event as event generator and CATB as user in PEVC module. During SleepWalking the required clocks will be enabled by the power manger. The required clocks need to be configured in “Peripheral Power Control Register (PPCR)”. ¾ Enable AST, CATB and PEVC clocks in the PPCR as follows. PPCR needs to be unlocked before changing its content.
Atmel AT04150: QTouch with SAM4L Training Guide [APPLICATION NOTE] 42180A−QTOUCH−09/2013
16
Enable interrupt by calling Enable_global_interrupt(). Enable Autonomous touch sensing by calling touch_autonomous_sensor_enable(). Enter sleep mode as follows. This will put the device in sleep till the touch button is touched. Call sleepmgr_init() before entering while(1) loop.
¾ Configure the AST periodic event as event generator and CATB as user in PEVC module. Enable PEVC peripheral clock.
Disable autonomous touch sensing when the device wakes up.
¾ Disable the AST periodic event as shown below.
Enable AST PER0 interrupt and initialize touch sensing as follows.
¾ Reset the “touch_sensor_idle_time” value to ‘0’. This need to be done even when the touch sensors are touched in periodic touch measurement.
Atmel AT04150: QTouch with SAM4L Training Guide [APPLICATION NOTE] 42180A−QTOUCH−09/2013
17
¾ Enable PEVC and PM clock after enabling CATB and PDCA clock as shown below.
5.3
Program the Output File ¾ Build the project and program the same to SAM4L-EK kit using Atmel Studio 6. ¾ After programming, Check LED0 status is updated based on touch button status. LED0 should glow when touch button CS0 is in “detect” state. The Autonomous touch gives the reduced power consumption value with 4µA during sleep and 25µA during autonomous touch sensing.
Atmel AT04150: QTouch with SAM4L Training Guide [APPLICATION NOTE] 42180A−QTOUCH−09/2013
18
6.
Task 5 – Reducing Power The objective of this task is to reduce the power consumption of the project developed in Task 1 (see Chapter 2), which consumes 3.55mA during untouched conditions. The OLED available in SAM4L-EK kit will be used to measure the current consumed by the SAM4LC4C device. Followings are the major factor that affects the power consumption ¾ System Clock Frequency. ¾ Sleep period and Active period. ¾ Current consumption of various peripherals during sleep. Use the project available in folder Exercise\Task5 for this Task.
6.1
System Clock Frequency The QTouch composer created project configures the system clock to 12MHz. Reducing the same to 4MHz will reduce the power consumption. The system clock frequency can be reduced by changing the “CONFIG_RCFAST_FRANGE” macro in “conf_clock.h” file. 0 – 4MHz 1 – 8MHz 2 – 12MHz ¾ Change the “CONFIG_RCFAST_FRANGE” to 0 and build the project. ¾ Program the code to the board and check the power consumed on the OLED. ¾ The average current displayed in the OLED should be reduced to 1.85mA during untouched conditions.
6.2
Enabling Sleep and Adjusting the Sleep Period The SAM4L supports various low power modes. Here we are going to see only WAIT mode. In WAIT mode only 32kHz clocks (RC32K, OSC32K) will be running, if enabled. The composer created project uses RC32K as the clock source for AST. AST can wake the CPU if the CPU is in WAIT mode. ¾ In main.c file, initialize the sleep manager and configure the AST to wake the device up by including the following code after touch_sensor_init().
¾ Execute the sleep command by introducing the following code inside the “touch measurement done if condition”.
Atmel AT04150: QTouch with SAM4L Training Guide [APPLICATION NOTE] 42180A−QTOUCH−09/2013
19
¾ Program the code to the board and check the power consumed on the OLED. ¾ The average current displayed in the OLED should be reduced to ~850µA. AST periodic interrupt is used as a timing reference for QTouch library and as scan rate to perform touch measurement. Reducing AST wake up periodicity will increase the period between two touch measurements. This will increase the sleep period and reduce the power consumption. This can be changed by changing the value sent on “ast_write_periodic0_value” function. AST wake up frequency is calculated by the following formula. Fast = Fcs / {2^(INSEL+1)}, where Fcs is the clock source for AST. In our case it is 32.768kHz. INSEL is the value that is passed in the ast_write_periodic0_value function. So, increasing the same will reduce the AST wakeup frequency and in turn reduces the power consumption. This will affect the touch response time. By default the QTouch composer configures the INSEL value as 9. Fast = 32768 / (2^(9+1)) = 32. So, 32 times the touch measurement will be performed per seconds. Touch measurement periodicity is 1/32 = 31.25msec. This value is updated in “TOUCH_MEASUREMENT_PERIOD_MS” macro in touch.c file. ¾ In main.c file, change the value passed in “ast_write_periodic0_value” function to 11. With 11, AST periodic interrupt will occur every 125msec. Update the macro “TOUCH_MEASUREMENT_PERIOD_MS” in touch.c file. ¾ Program the code to the board and check the power consumed on the OLED. ¾ The average current displayed in the OLED should switch between 780µA and ~868µA.
6.3
Disable CATB Clock before Going to Sleep Further power reduction can be achieved by stopping CATB module before going to sleep. This will reduce the overall power consumption. The CATB module can be stopped by writing ‘0’ to RUN bit in CATB control register. When the device wakes up from sleep, the CATB can again be set to start by writing ‘1’ to RUN bit. RUN bit status should be changed when the CATB module is in a definite state. The CATB module will be in a definite state when the touch measurement is completed (touch_qt_time.measurement_done_touch =1). ¾ In main.c file, include the CATB stop and start condition as shown below before and after sleepmgr_sleep().
¾ Program the code to the board and check the power consumed on the OLED. ¾ The average current displayed in the OLED should switch between 4µA and 145µA. 4µA is the current consumed during sleep and 145µA while performing touch measurement.
Atmel AT04150: QTouch with SAM4L Training Guide [APPLICATION NOTE] 42180A−QTOUCH−09/2013
20
7.
Task 6 – Including QDebug Interface The objective of this task is to enable QDebug interface to the touch project created using QTouch Composer. In Task 3 (see Chapter 4) the steps to create QTouch Composer project is discussed.
7.1
Opening Project For this task, user needs to open the project available in location “../Exercise/Task6/”. This project is created using QTouch Composer for SAM4L with one button and one slider similar to that of Task 2 (see Chapter 3). ¾ Open the project in Atmel Studio 6.1.
7.2
Enabling QDebug QDebug interface can be enabled using QTouch Project Builder wizard. In the Advanced option of QTouch Project Builder wizards, QDebug interface can be enabled. ¾ In the Solution Explorer of Atmel Studio 6.1, do a double click on “Task6.qtdgn”. The QTouch Project Builder wizard will start. Since all the parameters are already configured, go to Advanced Options page. ¾ Enable the QDebug interface by selecting the Check-Box. And select the interface and port pins as shown in Figure 7-1. Figure 7-1. QTouch Project Builder – Advanced Options.
¾ Click Next and then click Finish. Now this will add the QDebug protocol code to our QTouch Composer generated project.
Atmel AT04150: QTouch with SAM4L Training Guide [APPLICATION NOTE] 42180A−QTOUCH−09/2013
21
7.3
Connecting QT600 and SAM4L-EK Board ¾ Make the following connections between SAM4L-EK and QT600 board.
7.4
Pin description
SAM4L-EK
QT600 (TOUCH DATA Header)
SS
PC01 (J102.2)
5
MOSI
PC08 (J104.2)
6
MISO
PC13 (J105.2)
7
SCK
PC07 (J103.2)
8
Program the Output File ¾ Build the project and program the same to SAM4L-EK kit using Atmel Studio 6. ¾ After programming, connect the USB cable to QT600 board and open QTouch Analyzer in Atmel Studio 6.1. Real-time sensor data will be displayed in QTouch Analyzer as shown in Figure 7-2. Figure 7-2. QDebug Data in QTouch Analyzer.
Atmel AT04150: QTouch with SAM4L Training Guide [APPLICATION NOTE] 42180A−QTOUCH−09/2013
22
8.
Revision History Doc. Rev.
Date
Comments
42180A
09/2013
Initial document release
Atmel AT04150: QTouch with SAM4L Training Guide [APPLICATION NOTE] 42180A−QTOUCH−09/2013
23
Atmel Corporation
Atmel Asia Limited
Atmel Munich GmbH
Atmel Japan G.K.
1600 Technology Drive
Unit 01-5 & 16, 19F
Business Campus
16F Shin-Osaki Kangyo Building
San Jose, CA 95110
BEA Tower, Millennium City 5
Parkring 4
1-6-4 Osaki, Shinagawa-ku
USA
418 Kwun Tong Road
D-85748 Garching b. Munich
Tokyo 141-0032
Tel: (+1)(408) 441-0311
Kwun Tong, Kowloon
GERMANY
JAPAN
Fax: (+1)(408) 487-2600
HONG KONG
Tel: (+49) 89-31970-0
Tel: (+81)(3) 6417-0300
www.atmel.com
Tel: (+852) 2245-6100
Fax: (+49) 89-3194621
Fax: (+81)(3) 6417-0370
Fax: (+852) 2722-1369
© 2013 Atmel Corporation. All rights reserved. / Rev.: 42180A−QTOUCH−09/2013 Atmel®, Atmel logo and combinations thereof, Enabling Unlimited Possibilities®, QTouch®, and others are registered trademarks or trademarks of Atmel Corporation or its subsidiaries. ARM® and Cortex® are registered trademarks of ARM Ltd. Other terms and product names may be trademarks of others. Disclaimer: The information in this document is provided in connection with Atmel products. No license, express or implied, by estoppel or otherwise, to any intellectual property right is granted by this document or in connection with the sale of Atmel products. EXCEPT AS SET FORTH IN THE ATMEL TERMS AND CONDITIONS OF SALES LOCATED ON THE ATMEL WEBSITE, ATMEL ASSUMES NO LIABILITY WHATSOEVER AND DISCLAIMS ANY EXPRESS, IMPLIED OR STATUTORY WARRANTY RELATING TO ITS PRODUCTS INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, CONSEQUENTIAL, PUNITIVE, SPECIAL OR INCIDENTAL DAMAGES (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS AND PROFITS, BUSINESS INTERRUPTION, OR LOSS OF INFORMATION) ARISING OUT OF THE USE OR INABILITY TO USE THIS DOCUMENT, EVEN IF ATMEL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. Atmel makes no representations or warranties with respect to the accuracy or completeness of the contents of this document and reserves the right to make changes to specifications and products descriptions at any time without notice. Atmel does not make any commitment to update the information contained herein. Unless specifically provided otherwise, Atmel products are not suitable for, and shall not be used in, automotive applications. Atmel products are not intended, authorized, or warranted for use as components in applications intended to support or sustain life.