EFM32外设模块—LESENSE V1.00
EFM32外设模块—OPAMP V1.10

目录1. 适用范围................................................................................. 错误!未定义书签。
2. 原理概述................................................................................. 错误!未定义书签。
3. 开发环境................................................................................. 错误!未定义书签。
4. 技术实现................................................................................. 错误!未定义书签。
5. 参考资料................................................................................. 错误!未定义书签。
6. 免责声明................................................................................. 错误!未定义书签。
1. 概述运算放大器(Operational Amplifier,简称OPAMP)是EFM32系列微控制器片上模拟外设,经过恰当地选取外部元件,它能够实现各种模拟运算,如放大、加、减、微分和积分等。
EFM32芯片内拥有三个运算放大器(Gecko系列芯片内部没有运算放大器),分别为OPA0、OPA1和OPA2。
其中OPA0和OPA1是DAC模块的一部分,OPA2为独立的运算放大器。
OPAMP模块框图如图1.1所示。
图1.1 OPAMP模块框图这三个运算放大器可以相互配合并通过搭配合适的外部电路和内部反馈满足复杂的应用需求。
EFM32 ZG 微控制器产品说明书

V
0.8VDD
V
0.25VDD
0.3VDD
V
0.05VDD
0.2VDD
V
0.3VDD
0.35VDD
V
0.1VDD
0.25VDD
V
±25
±0.1
±100
nA
0.8
1.5
0.7
1.75
kHz
10Βιβλιοθήκη 0mVW7206F2 Silicon Labs Bulletin rev H The information contained in this document is PROPRIETARY to Silicon Laboratories, Inc. and shall not be reproduced or used in part or whole without Silicon Laboratories’ written consent. The document is uncontrolled if printed or electronically saved. Pg 4
This change is considered a minor change which does not affect form, fit, function, quality, or reliability. The information is being provided as a customer courtesy.
See Table 1 at the end of this document for additional details.
The reference manual has also been changed to reflect the updated operating voltage range and current consumption information.
EFM32外设模块—GPIO V1.10

目录1. 概述 (1)2. FAQ (2)2.1 GPIO功能描述 (2)2.2 GPIO功能结构 (2)2.3 GPIO寄存器配置 (2)2.4 GPIO中断配置 (3)2.5 GPIO的低功耗特点 (4)3. 实验指导 (5)3.1 实验目的 (5)3.2 实验设备 (5)3.3 实验内容 (5)3.4 试验步骤 (5)3.5 实验参考程序 (5)3.6 实验结果 (7)4. 免责声明 (8)1. 概述通用输入输出(General Purpose Input/Output,简称GPIO)是EFM32片上的通用引脚输入和输出接口外设,其能够提供灵活的引脚功能配置,同时也是片上外设对外的接口。
其主要特点如下:z最多93个GPIO引脚;z引脚配置;上拉/下拉电阻;输入/输出使能;输出驱动能力(0.5 / 2 / 6 / 20 mA);输入滤波器。
z16个异步外部中断;z片上外设引脚重映射;z最多6个引脚支持从EM4唤醒。
2. FAQ2.1 GPIO功能描述1. GPIO的主要作用有哪些?A:通用输入输出(General Purpose Input/Output,GPIO)是通用引脚输入和输出接口,其能够提供灵活的引脚功能配置,同时也是片上外设对外的接口。
GPIO还具有从EM4模式中唤醒功能。
2. 怎样利用与GPIO相关的emlib库函数?A:首先将em_gpio.c文件加入工程中,然后在需要调用与GPIO相关的emlib库函数的源文件中添加如程序清单2.1所示的预编译代码。
程序清单2.1 GPIO头文件#include "em_gpio.h"2.2 GPIO功能结构1. EFM32系列的GPIO管脚是如何命名的?A:EFM32系列MCU的引脚组织为每个端口16个引脚,每个独立的GPIO引脚命名为Pxn,x表示端口号(A,B,C…),n表示引脚号(0,1,…,15)。
2. 复位后GPIO处于何种状态?A:复位后,除了调试引脚外(对于EFM32系列微控制器来说,一共有3个调试引脚,分别为:SWCLK、SWDIO和SWV。
EFM32外设模块—WDOG V1.00

产品应用笔记
©2012 Guangzhou ZLG MCU Technology Co., Ltd. 1
广州周立功单片机科技有限公司
WDOG
EFM32 系列微控制器
2. FAQ
1. 怎样使用与看门狗定时器相关的 emlib 库函数? A:首先将 em_wdog.c 文件加入工程中,然后在需要调用与看门狗定时器相关的 emlib 库函数的源文件中添加如所示的预编译代码。
程序清单 3.2 主函数
int main (void) {
INT32U ulResetCause;
CHIP_Init();
ulResetCause = RMU_ResetCauseGet(); RMU_ResetCauseClear();
/* 获取 RMU_RSTCAUSE 寄存器的值 */
/* 清除复位事件标志
/*
* 看门狗定时器配置结构体,在使用看门狗时该结构体有用
*/
WDOG_Init_TypeDef tWdogInit = {
.enable = true, .debugRun = false, .em2Run = true,
/* 使能看门狗
*/
/* 看门狗在调试时不计数
*/
/* 在 EM2 模式看门狗继续计数
EFM32 片上看门狗定时器可选的时钟源包括内部 32.768kHz RC 振荡器、内部 1kHz RC 振荡器和 32.768kHz 外部晶体振荡器。不同于一般 MCU 的看门狗定时器,EFM32 片上看门 狗定时器不是通过配置计数器顶端值等操作确定看门狗溢出周期,而是从给定的溢出周期选 项中选择看门狗定时器溢出周期,溢出周期可选范围为 9~256k 个看门狗模块时钟周期。
EFM32 I2C模块操作指南说明书

...the world's most energy friendly microcontrollersI2C Master and Slave OperationAN0011 - Application NoteIntroductionThe EFM32 I2C module allows simple, robust and cost effective communicationbetween integrated circuits using only one data and one clock line.This application note demonstrates how to use the EFM32 I2C module to talk to anI2C temperature sensor. It also includes a software example where two EFM32s are connected; each EFM32 will operate in either slave or master mode and talk to theother one.This application note includes:•This PDF document•Source files (zip)•Example C-code•Multiple IDE projects1 I2C Theory1.1 GeneralThe I2C allows connection of up to 128 individually addressable devices using only two bi-directional lines: clock (SCL) and data (SDA). The only additional hardware required is a pull-up resistor for each of the lines. Each of the connected devices can be either a master or slave device. Only master devices are allowed to drive the clock line.The I2C protocol and the EFM32 I2C module feature several mechanisms for handling bus conflicts and contention. A possible I2C connection scheme is illustrated in Figure 1.1 (p. 2) .Figure 1.1. I2C BuspS DAS CLAt the physical layer both SCL and SCA lines are in open-drain, hence the pull-up resistors. Increasing the number of devices on the I2C bus will also increase the line capacitance and thus reduce the slew-rate. The slew-rate can be controlled by changing the drive strength in the GPIO module for the I2C pins. The size of the pull-up resistors can be calculated as a function of the maximum rise time allowed for the given bus speed and the estimated bus capacitance Cb as shown in Equation 1.1 (p. 2)Pull-up Resistor EquationRp(max) = tr/0.8473 x Cb(1.1)The maximal rise times for 100 kHz, 400 kHz and 1 MHz I2C are 1 µs, 300 ns and 120 ns respectively.1.2 I2C Signals/FramesSTART and STOP conditions are used to initiate and stop transactions on the I2C-bus. All transactions on the bus begin with a START condition (S) and end with a STOP condition (P). As illustrated in Figure 1.2 (p. 3) , a START condition is generated by pulling the SDA line low while SCL is high, and a STOP condition is generated by pulling the SDA line high while SCL is high.Also illustrated in Figure 1.2 (p. 3) is I2C bit transfer. Note that data must be stable for the whole duration of the SCL high period.Figure 1.2. Start, Stop and DataS CLS DAS P S TART condition S TOP condition S CLS DAData stableData changeallowed Data changeallowedI2C S tart and S top I2C Bit transferA master initiates a transfer by sending a START followed by the address of the slave it wishes to contactand a single R/W bit telling whether it wishes to read from (R/W = 1) or write to the slave (R/W = 0).After the 7-bit address and the R/W bit, the master releases the bus, allowing the slave to acknowledge the request. During the next bit-period, the slave pulls SDA low (ACK) if it acknowledges the request, or keeps it high if it does not acknowledge it (NACK). Following the address acknowledge, either the slave or master transmits data, depending on the value of the R/W bit. After every 8-bit byte transmitted on the SDA line, the transmitter releases the line to allow the receiver to transmit an ACK or a NACK. Both the data and the address are transmitted with the most significant bit first.The master ends the transmission after a (N)ACK by sending a STOP condition on the bus. After a STOP condition, any master can initiate a new transfer.An example of a master writing to a slave is shown in Figure 1.3 (p. 3) . The identifiers used are: S - Start bit, ADDR - Address, W - Write(0), A - ACK, N - NACK, DATA - Data, P - Stop bit.Figure 1.3. Master Write to SlaveFor further details about I2C and the EFM32 I2C module, please see the EFM32 reference guide. 1.3 ArbitrationAs the I2C bus is a multi-master bus it is possible that two devices initiate a transfer at the exact same time (e.g. RTC tick). When this happens the first device attempting to transmit a logical 1 while another device transmits a logical 0 will lose arbitration. The device attempting to transmit 1 will detect that the line is low when it should actually be high so assumes that another master is active and immediately stops its transfer. This device will then wait until the next STOP condition before trying to transmit again.1.4 Clock stretchingAn addressed slave device may hold the clock line (SCL) low after receiving (or sending) a byte, indicating that it is not yet ready to process more data. The master communicating with the slave will try to raise the clock to transfer the next bit but will verify that the clock line will remain low. The master will then have to wait for the slave to release the line so that the clock signal can be transmitted. If a master wants to slow down the rate of data transfer it just delays the next clock edge.2 Software Examples2.1 Master Operation with InterruptsThis software example uses the efm32_i2c library to read a DS75 digital thermometer mounted on the EFM32_G890_DK development kit. The tempsens driver includes an interrupt routine to demonstrate how to use the efm32_i2c library in interrupt driven mode.2.1.1 Program FlowThe EFM32 reads the temperature sensor every 2 seconds and stays in a low power mode between measurements. The measurement results are converted to either Celsius or Fahrenheit and displayed on the segment LCD.The efm32_i2c library can be used both in polled and interrupt driven mode. This example uses the interrupt driven approach, but still has a while loop which blocks the function reading the temperature until the transfer is finished. The I2C interrupt routine is entered every time the I2C module generates an interrupt, then it is up to the state machine in the efm32_i2c library to handle and clear the active interrupt flags.Interrupts are generated every time the I2C-peripheral is finished with an autonomous task, or when it detects fault conditions which should be handled by software. Not all possible interrupts are handled or used by this code example.2.1.2 ConnectionsThe software example is specifically made for the development kit and includes the board support package to enable the correct connections and initialize the temperature sensor from software.2.2 Master and Slave OperationThis software example makes the EFM32 operate in both master and slave configuration. Two EFM32 I2C modules are connected and set up to both transmit (master mode) and receive data between each other (slave mode) using a common I2C bus.The code example included is written for the EFM32_Gxxx_DK development kit, but is easily ported to any EFM32 part with an I2C-peripheral.2.2.1 Program FlowEach EFM32 has enabled I2C address match interrupt and Real Time Counter (RTC) interrupt. Both these interrupts are capable of waking up the EFM32 from Deep Sleep mode (EM2), hence the idle state current consumption is extremely low.The I2C is continuously monitoring the I2C line. If a start condition followed by the I2Cs defined address, an address match interrupt is issued and data is received until a stop condition is detected.The Real Time Counter (RTC) is set to wake up the EFM32 regularly. If a reception is not in progress at the time of wake-up, a master transmission is initiated. The address match interrupt is disabled during the transmission and re-enabled afterwards.The operation is illustrated in the state diagram shown in Figure 2.1 (p. 5)Figure 2.1. Program state machineDuring transmission, the PC0 pin is set in order to determine transfer direction for example by using a logic analyzer. On the starter kit, this pin is connected to LED0, which is lit during transmission.Please refer to the source code for further details.2.2.2 ConnectionsThe software example uses location 1 for the SCL (PD7) and SDA (PD6) pins. Connect the PD6 pins and the PD7 pins of the EFM32s, respectively. The configuration is illustrated in Figure 2.2 (p. 5) Figure 2.2. ConnectionIn the GPIO module of the EFM32 the pull-up resistors have been enabled, hence external pull-up resistors are not necessary to make the example work. However, external resistors are generally preferable as they keep the lines defined at all times. For example, when the EFM32 is in reset-state, the pull-up configuration in the GPIO module is not available, which leaves the I2C bus undefined.3 Revision History3.1 Revision 1.062013-09-03New cover layout3.2 Revision 1.052013-05-08Added software projects for ARM-GCC and Atollic TrueStudio.3.3 Revision 1.042012-11-12Adapted software projects to new kit-driver and bsp structure.3.4 Revision 1.032012-04-20Adapted software projects to new peripheral library naming and CMSIS_V3.3.5 Revision 1.022012-03-22Added description on slew rate control.Added arbitration and clock stretching sections (1.3 and 1.4).Added a software example with interrupt driven master operation.Changed name of application note.3.6 Revision 1.0116-11-2010Removed clearing of RXDATAV interrupt flag through I2C_IFC since this operation is ignored.Changed example folder structure, removed build and src folders.Added chip-init function.3.7 Revision 1.0020-09-2010.Initial revision.A Disclaimer and TrademarksA.1 DisclaimerSilicon Laboratories intends to provide customers with the latest, accurate, and in-depth documentation of all peripherals and modules available for system and software implementers using or intending to use the Silicon Laboratories products. Characterization data, available modules and peripherals, memory sizes and memory addresses refer to each specific device, and "Typical" parameters provided can and do vary in different applications. Application examples described herein are for illustrative purposes only. Silicon Laboratories reserves the right to make changes without further notice and limitation to product information, specifications, and descriptions herein, and does not give warranties as to the accuracy or completeness of the included information. Silicon Laboratories shall have no liability for the consequences of use of the information supplied herein. This document does not imply or express copyright licenses granted hereunder to design or fabricate any integrated circuits. The products must not be used within any Life Support System without the specific written consent of Silicon Laboratories.A "Life Support System" is any product or system intended to support or sustain life and/or health, which,if it fails, can be reasonably expected to result in significant personal injury or death. Silicon Laboratories products are generally not intended for military applications. Silicon Laboratories products shall under no circumstances be used in weapons of mass destruction including (but not limited to) nuclear, biological or chemical weapons, or missiles capable of delivering such weapons.A.2 Trademark InformationSilicon Laboratories Inc., Silicon Laboratories, the Silicon Labs logo, Energy Micro, EFM, EFM32, EFR, logo and combinations thereof, and others are the registered trademarks or trademarks of Silicon Laboratories Inc. ARM, CORTEX, Cortex-M3 and THUMB are trademarks or registered trademarks of ARM Holdings. Keil is a registered trademark of ARM Limited. All other products or brand names mentioned herein are trademarks of their respective holders.B Contact InformationSilicon Laboratories Inc.400 West Cesar ChavezAustin, TX 78701Please visit the Silicon Labs Technical Support web page:/support/pages/contacttechnicalsupport.aspx and register to submit a technical support request.Table of Contents1. I2C Theory (2)1.1. General (2)1.2. I2C Signals/Frames (2)1.3. Arbitration (3)1.4. Clock stretching (3)2. Software Examples (4)2.1. Master Operation with Interrupts (4)2.2. Master and Slave Operation (4)3. Revision History (6)3.1. Revision 1.06 (6)3.2. Revision 1.05 (6)3.3. Revision 1.04 (6)3.4. Revision 1.03 (6)3.5. Revision 1.02 (6)3.6. Revision 1.01 (6)3.7. Revision 1.00 (6)A. Disclaimer and Trademarks (7)A.1. Disclaimer (7)A.2. Trademark Information (7)B. Contact Information (8)B.1. (8)List of Figures1.1. I2C Bus (2)1.2. Start, Stop and Data (3)1.3. Master Write to Slave (3)2.1. Program state machine (5)2.2. Connection (5)...the world's most energy friendly microcontrollers List of Equations1.1. Pull-up Resistor Equation (2)。
EFM32外设模块—LCD V1.00

目录1. 概述 (1)2. FAQ (2)3. 实验指导 (3)3.1 实验目的 (3)3.2 实验设备 (3)3.3 实验内容 (3)3.4 试验步骤 (3)3.5 实验参考程序 (3)3.6 实验结果 (4)4. 免责声明 (6)1. 概述液晶显示驱动(Liquid Crystal Display Driver,简称LCD)是EFM32片上的低功耗外设,其能够直接驱动段式液晶实现图形显示,并能够工作于EM0~EM2模式下,在EM2模式下工作时其最低功耗小于900nA。
EFM32片上LCD模块具有升压功能,其能够在电压低至2.0V时将电压升压至3.6V,即使在电池供电应用中当其电压不足时也能够让LCD正常显示。
同时为了更好的适应不同的液晶面板和外部环境变化,LCD模块可以根据实际应用调节显示对比度,使得LCD模块的应用更加灵活;并且LCD模块还具备动画、闪烁等特性,让LCD能够在不需要CPU干预的情况下即可完成动画显示和闪烁功能,因此MCU可以长时间处于低功耗模式,降低系统功耗。
2. FAQ1. LCD的供电方式有哪些?A:LCD供电可以选择内部V DD或是外部电源/V BOOST供电。
当使用V BOOST功能时,需要在LCD_BEXT引脚连接一个1μF的电容到地,并在LCD_BCAP_P和LCD_BCAP_N引脚之间加一个22nF的电容。
根据实际需求,LCD模块的升压功能可以将LCD电压升压至3.0~3.6V。
2. 如何使能或禁能LCD模块的V boost功能?A:LCD模块V boost功能的使能或禁能位于CMU模块中,通过配置CMU_LCDCTRL 寄存器中VBOOSTEN位可实现V boost功能的使能或禁能,该位置0则禁能,置1则使能。
3. LCD调节对比的目的是什么?A:不同LCD面板之间它们的特性略有不同,即使是同一LCD面板在不同的温度下其特性也会发生变化。
当由于某种因素导致控制LCD显示的电压与LCD面板当前的显示阀值电压过于接近时候会产生重影或者显示异常等现象,此时可以通过调节LCD对比度让控制LCD显示的电压与当前LCD面板的显示阈值电压之差变大的方式解决上述问题。
EFM32外设模块—LEUART V1.10

广州周立功单片机科技有限公司
LEUART
EFM32 系列微控制器
目录
1. 概述...........................................................................................................................1
广州周立功单片机科技有限公司
LEUART
EFM32 系列微控制器
检查串口调试助手设置的波特率。
b)LEUART 的时钟精度不够高。对于 EFM32 来说,LEUART 的时钟源可能来自于内 部 RC 振荡器和外部的晶体谐振器。内部 RC 振荡器起震快功耗小但是精度低,而外部晶体 谐振器起震较慢功耗较大但是精度高。所以,为了保证通信的质量,在使用 Energy Micro 的 LEUART 时,一般会使用外部晶体振荡器。
2.2 LEUART 寄存器配置
1. 如何正确使用 RXDATA、RXDATAX、RXDATAXP 寄存器? A:它们都是接收数据寄存器;其中 RXDATAX、RXDATAXP 还包含状态信息。这些 状态信息主要包括:
EFM32外设模块—AES V1.00

产品应用笔记
©2012 Guangzhou ZLG MCU Technology Co., Ltd. 1
广州周立功单片机科技有限公司
AES
EFM32 系列微控制器
2. FAQ
2.1 基本功能
1. AES 有哪 5 种加密模式? A:AES 加密最基本的方式是 ECB,以 ECB 模式为基础,通过不同数据块的异或处理,
3.3 实验内容
本实验主要演示利用 EFM32 片上 AES 实现 ECB 加解密。 实验例程利用 ECB 加解密方式对预定明文进行加密和解密实验,解密完成后通过对比 解密结果和原始明文验证加解密操作的正确性。
3.4 试验步骤
1) 连接开发板 USB 端口到电脑的 USB 端口,打开 MCU 电源; 2) 打开 Keil(或 IAR)工程,重新编译并调试运行; 3) 单步运行完加密函数段后查看加密结果; 4) 单步运行完解密函数段后查看解密结果并比对原始明文。
3.4
试验步骤 ................................................................................................................... 3
3.5
实验参考程序 ........................................................................................................... 3
产生不同的加密模式,共有如下 5 种加密模式。 1) ECB 模式:将明文分割成几个 128 位的数据块,利用密钥对每个数据块进行加密 和解密。加密或解密后的结果大小完全不变,而且独立,互相之间不关联,便于并 行运算; 2) CBC 模式:建立在 ECB 模式上使用的一种加密方法。CBC 算法中,每个明文块先 与前面的秘文块相异或,然后再加密。加密的数据相互关联,不能并行处理,但破 解的难读很大; 3) CFB 模式:密钥先与前一个密文块加密,之后再与当前明文块取异或。每个密文 块都与后面的步骤紧密相连,任何一个密文块损坏,都无法完成解密; 4) OFB 模式:与 CFB 的区别在于,OFB 模式下密钥与前一块加密的结果加密; 5) CTR 模式:一种用明文块与一个计数器密码和一个初始化向量的值进行异或运算 的方法。这种方法的价值在于,只要知道数据块所在的位置,就可以对任何一个明 文块进行解密。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
产品应用笔记
©2012 Guangzhou ZLG MCU Technology Co., Ltd. 2
广州周立功单片机科技有限公司
LESENSE
EFM32 系列微控制器
3. 实验指导
3.1 实验目的
掌握 Energy Micro EFM32 系列微控制器 LESENSE 的特性并能够利用 LESENSE 构建简 单应用。
/* 偏置电流配置
*/
.hysteresisLevel .vddLevel .resistor
= acmpHysteresisLevel5, /* 配置 ACMP 滞回电压
*/
= 0x30,
/* 配置 VDD 参考电压分压值
*/
= acmpResistor0
/* 电容感应回路中串联电阻选择
*/
};
/* * ACMP 电容感应模式配置 */ ACMP_CapsenseInit(ACMP0, &tAcmpCapInit); }
产品应用笔记
©2012 Guangzhou ZLG MCU Technology Co., Ltd.
4
广州周立功单片机科技有限公司
LESENSE
EFM32 系列微控制器
.warmTime
= acmpWarmTime512, /* 预热时间有 LESENSE 控制
*/
.lowPowerReferenceEnabled = false,
4. 免责声明.................................................................................................................12
产品应用笔记
©2012 Guangzhou ZLG MCU Technology Co., Ltd. 1
2. FAQ ............................................................................................................................ 2
3. 实验指导...................................................................................................................3
/* 开启 LESENSE 时钟
*/
/* * PC5 作为电容按键输入,因此 GPIO 需配置为输入输出禁能的浮空状态。
*/
GPIO_PinModeSet(gpioPortC, 5, gpioModeDisabled, 0);
/* * LESENSE 作为电容传感器应用时不需要 DAC,因此不用配置 DAC
3.5
实验参考程序 ........................................................................................................... 3
3.6
实验结果 ................................................................................................................. 10
ห้องสมุดไป่ตู้
3.1
实验目的 ................................................................................................................... 3
3.2
实验设备 ................................................................................................................... 3
/* 禁能低功耗参考电压模式
*/
.enable
= false,
/* 由 LESENSE 控制使能 ACMP
*/
/* * 以下配置根据实际应用配置
*/
.fullBias .halfBias .biasProg
= true, = true, = 0x05,
/* 全偏置电流开启
*/
/* 减半偏置电流开启
*/
LESENSE
EFM32 系列微控制器
EMU_EnterEM2(false);
/* 进入 EM2 深度睡眠模式
*/
}
}
在 LESENSE 容性传感器应用初始化函数中,先配置所需时钟,开启相关模块时钟,在 配置 LESENSE 时钟时,为了得到较高的测量精度,使用 LFXO 作为 LFA 的时钟源。由于 只使用通道 5,因此只需配置通道 5 对应的 PC5 引脚即可。最后调用 ACMP 初始化函数和 LESENSE 初始化函数并清零按键标志位。具体实现代码如程序清单 3.2 所示。
capacitiveInit();
/* 初始化 LESENSE 容性传感器应用 */
LESENSE_ScanStart();
/* 启动 LESENSE 扫描
*/
while(1) {
产品应用笔记
©2012 Guangzhou ZLG MCU Technology Co., Ltd. 3
广州周立功单片机科技有限公司
程序清单 3.2 LESENSE 容性传感器应用初始化函数
void capacitiveInit (void)
{
/*
* PC5 作为电容按键输入,因此只需要开启 ACMP0 的时钟。
*/
CMU_ClockEnable(cmuClock_ACMP0, true);
CMU_ClockEnable(cmuClock_GPIO, true);
图 1.1 LESENSE 结构框图
产品应用笔记
©2012 Guangzhou ZLG MCU Technology Co., Ltd. 1
广州周立功单片机科技有限公司
LESENSE
EFM32 系列微控制器
2. FAQ
1. LESENSE 的扫描序列有哪些触发方式? A:扫描序列有 PRS 触发、单次触发和周期触发三种触发方式。 PRS 触发:通过 PRS 通道进行触发启动扫描; 单次触发:软件触发启动单次扫描; 周期触发:启动扫描后每次模块内部周期计数器溢出则再次启动扫描。 2. LESENSE 的传感器扫描时序哪些需要注意? A:LESENSE 有两个可选的时钟源。一个低频时钟源,工作在 LFACLKLESENSE 时钟下。 一个是高频时钟源,工作在 AUXHFRCO 时钟下。激励时间长度、采样延迟可以根据实际需 要选择 LFA 或 AUXHFRCO 作为其时钟源,而启动延迟和测量延迟则只能选择 LFA 作为其 时钟源。 3. LESENSE 支持的解码形式是什么? A:LESENSE 只支持 16 种状态的可编程状态机。它的输入是由四个位组成的可表达 16 种状态的编码。四个状态位可以由通道采样结果组成,也可以由 PRS 通道的输入组成。 4. LESENSE 的存储结果使用时需要注意什么? A:LESENSE 的结果缓存是由 16 个半字组成的循环队列。它映射在 LESENSE 内部 RAM 中,对这部分 RAM 进行访问时需要确保其未被禁能。
如程序清单 3.4 所示为 LESENSE 初始化函数。在该函数中主要完成 LESENSE 整体配 置和 LESENSE 通道配置。其中 LESENSE 总体配置中又分为 LESENSE 内核、测量时序和 LESENSE 所使用外设和译码器等四个部分的初始化工作。其中译码器部分在本实验例程中 未使用到。在 LESENSE 通道配置中将采样时间设为 127 个模块时钟周期以获取足够的计数 值,而阈值则根据实际的测量设置为 1200 并配置当计数器值低于阈值时产生中断。配置 LESENSE 每秒钟扫描 5 次,最后开启 LESENSE 总中断。
3.2 实验设备
z 硬件:PC 机一台和 EFM32TG-STK3300 开发板一套; z 软件:IAR(或 Keil)集成开发环境。
3.3 实验内容
本实验主要演示如何使用 LESENSE 实现电容触摸按键应用。 在实验例程中使用 LESENSE 的输入通道 5 检测电容触摸按键的输入,当检测到手指触 摸时 LED 将被点亮,而当手指离开触摸按键时 LED 则被熄灭。
*/ setupACMPCapacitive(); setupLESENSECapacitive();
/* 配置 ACMP 模块
*/
/* 配置 LESENSE 模块
*/
__GucCapButtonFlag = 0;
/* 清 0 标志位
*/
}
在 ACMP 模块的配置中,由于是容性传感器应用,因此选择容性传感器应用配置结构 体初始化 ACMP 模块,其中偏置电流、滞回电压、VDD 分压值和电容感应回路中串联电阻 值等需根据实际应用需求配置。具体实现代码如程序清单 3.3 所示。
3.4 试验步骤
1) 连接开发板 USB 端口到电脑的 USB 端口,打开 MCU 电源; 2) 打开 Keil(或 IAR)工程,重新编译并下载程序; 3) 打开 Simplicity Studio 软件,点击 energyAware Profiler 图标项打开 AEM 监控软件
监控 MCU 运行功耗; 4) 复位 MCU,用手指触摸开发板 TOUCH SLIDER 最左边的触摸按键,观察 LED 灯
广州周立功单片机科技有限公司