User Guide RN4020 (Microchip) - 15

FabricanteMicrochip
DescripciónBluetooth Low Energy Module
Páginas / Página104 / 15 — RN4020 BLUETOOTH LOW ENERGY. MODULE USER’S GUIDE. Chapter 2. RN4020 …
Formato / tamaño de archivoPDF / 945 Kb
Idioma del documentoInglés

RN4020 BLUETOOTH LOW ENERGY. MODULE USER’S GUIDE. Chapter 2. RN4020 Command Interface. 2.1. RN4020 CONTROL LINES

RN4020 BLUETOOTH LOW ENERGY MODULE USER’S GUIDE Chapter 2 RN4020 Command Interface 2.1 RN4020 CONTROL LINES

Línea de modelo para esta hoja de datos

Versión de texto del documento

link to page 64 link to page 15 link to page 20 link to page 80 link to page 23
RN4020 BLUETOOTH LOW ENERGY MODULE USER’S GUIDE Chapter 2. RN4020 Command Interface
The RN4020 module is a fully certified Bluetooth Low Energy single mode OEM module. The module is controlled by the user through input/output lines (i.e., physical device pins) and a UART interface. The UART Interface supports ASCII commands to control/configure the RN4020 modules for any specific requirement based on the application. The following topics are included in this chapter: • RN4020 Control Lines • RN4020 UART-ASCII Command and Responses • Device Firmware Upgrade
2.1 RN4020 CONTROL LINES
The RN4020 module uses the WAKE_SW (pin 7), CMD/MLDP (pin 8), WAKE_HW (pin 15) pins to place the module into different states, and three output pins to indicate its current status. WAKE_SW is used to control the operating state of the RN4020. When WAKE_SW is set high, the module wakes up and is set into Active mode. Upon waking up, “CMD” will be output to the UART and indicate that the module is in Command mode and ready to take commands from UART. Conversely, when WAKE_SW is set low, the module exits Command mode by outputting “END” to the UART, and then operates in Deep Sleep mode. The UART interface will not be responsive in Deep Sleep mode unless the UART baud rate is 2400 bps. When the module is in Deep Sleep mode, MLDP_EV (pin 11) will be held low. CMD/MLDP (pin 8) is used to control the RN4020 module when an MLDP serial data service (see
Section 2.3.7 “Microchip MLDP Commands”
) is used. Once MLDP mode is entered by setting CMD/MLDP high, all data from the UART is sent to the peer device as a data stream. To exit MLDP mode, CMD/MLDP must be set low so that the RN4020 module is returned to Command mode by outputting “CMD” to the UART. Setting WAKE_HW (pin 15) high wakes the RN4020 module from Dormant mode. After powering up, if WAKE_HW flips up and down three cycles (putting the WAKE_HW pin into high, and then low, and then high again is considered one flip cycle) in the first five seconds, the RN4020 module performs a factory Reset. If WAKE_SW is high when a factory Reset is performed, the factory Reset is complete; otherwise, it is a partial factory Reset that retains the device name, private service, and scripts. Refer to
Section 2.3.1 “Set/Get Commands”
for information on “SF,1” describing factory default. When the RN4020 module is connected to a peer device, SCK/PIO1 – CONNECTION LED (pin 10) will output high; otherwise, CONNECTION LED outputs low. When in MLDP mode, if the RN4020 module must output a status to the UART or is requesting a response from the host MCU, MLDP_EV will be set high. Once the RN4020 module exits MLDP mode and returns to Command mode, status and/or requests will be output to the UART. Once stored data is output to the UART,  2014 Microchip Technology Inc. DS70005191B-page 15 Document Outline Preface Introduction Document Layout Conventions Used in this Guide Recommended Reading The Microchip Web Site Development Systems Customer Change Notification Service Customer Support Document Revision History Chapter 1. Introduction 1.1 Bluetooth Low Energy Fundamentals Table 1-1: Characteristic Properties Chapter 2. RN4020 Command Interface 2.1 RN4020 Control Lines Figure 2-1: RN4020 Module Pin Diagram Table 2-1: RN4020 Module Pin Description 2.2 GAP Role Switching Table 2-2: Role Switch Commands 2.3 RN4020 UART-ASCII Command and Responses Table 2-3: RN4020 UART Configuration Table 2-4: Command Descriptions 2.3.1 Set/Get Commands Example 2-1: Set Command Format Table 2-5: UART Baud Rate Settings Table 2-6: SP Level/TX Power Out Table 2-7: Bitmap Features Table 2-8: Bitmap Services Table 2-9: Connection Parameters 2.3.2 Action Commands Table 2-10: Bitmap of “|O” and “|I” Commands 2.3.3 I2C™ Commands Table 2-11: I2C™ Commands 2.3.3.1 Enable I2C 2.3.3.2 Disable I2C 2.3.3.3 I2C EEPROM Access 2.3.3.4 I2C Basic Operations Table 2-12: I2C™ Events 2.3.3.5 Example of Accessing the Microchip I2C EEPROM 24LC512 Figure 2-2: Writing Data via the I2C™ Interface Figure 2-3: Reading Data via the I2C™ Interface 2.3.4 PWM Commands Figure 2-4: PWM Waveform Table 2-13: PWM Parameters 2.3.5 Characteristic Access Commands 2.3.5.1 Definition of Characteristic Access Commands Example 2-2: Listing Client Service and Characteristics 2.3.6 Private Service Configuration Commands Table 2-14: Security flags of characteristic 2.3.7 Microchip MLDP Commands 2.3.7.1 Microchip Low-Energy Data Profile (MLDP) 2.3.7.2 MLDPv2 2.3.8 RN4020 Scripting Commands 2.3.8.1 RN4020 Scripting Capabilities 2.3.8.2 Event Driven Table 2-15: List of Events and Event Labels 2.3.8.3 Comments 2.3.8.4 Variables 2.3.8.5 Remote Function Call Example 2-3: Function Example 2.3.9 RN4020 Script Commands Table 2-16: “WR” Command Input Parameters and Associated Events 2.3.10 Remote Command 2.4 Summary of RN4020 UART Outputs 2.4.1 ASCII Commands with Non-Standard Response Table 2-17: Non-Standard Response for ASCII Commands 2.4.2 UART Response to PIO Switches Table 2-18: UART Response to PIO Events 2.4.3 UART Notifications Table 2-19: UART Notification 2.5 Device Firmware Upgrade 2.5.1 DFU Commands Chapter 3. Application Examples 3.1 Demonstration with a Smart Device 3.1.1 Setup 3.1.2 Running the Demonstration Figure 3-1: Discovering the RN4020 Module Figure 3-2: Reading the Model Number String From the Device Information Service Figure 3-3: Reading Battery Level in Battery Service Figure 3-4: Notification Result of Battery Level Example 3-1: User-Defined Private Services Figure 3-5: Private Services Discovered After Power Cycle Figure 3-6: Reading the Private Characteristic Figure 3-7: Writing Values to Private Characteristics Figure 3-8: Notification to Private Characteristic 3.2 Connecting Two RN4020 Modules 3.2.1 Configure the First Device (Module A) 3.2.2 Configure the Second Device (Module B) 3.2.3 Connecting the Two Devices 3.2.4 Checking Server and Client Services Table 3-1: Module A Server and Client Services Table 3-2: Module B Server and Client Services 3.2.5 Setting the Battery Service 3.3 MLDP Demonstration 3.4 RN4020 Scripting Demonstration 3.4.1 Setting Up Private Service and Characteristics 3.4.2 Script Input 3.4.3 Running the Script Appendix A. PICtail™ Daughter Board Schematics Figure A-1: RN4020 Module Figure A-2: PIC18LF25K50-I/ML Device Figure A-3: 28-pin and 30-pin PICtail™ Connectors Figure A-4: RN4020 Module Breakout Pins Figure A-5: Status LEDs Figure A-6: Voltage Regulator Figure A-7: Decoupling Capacitor for the PIC18LF25K50-I/ML Device Figure A-8: Test Switch Figure A-9: ICSP™ Connector Corporate Office Atlanta Austin, TX Boston Chicago Cleveland Fax: 216-447-0643 Dallas Detroit Houston, TX Indianapolis New York, NY San Jose, CA Canada - Toronto Fax: 852-2401-3431 Australia - Sydney China - Beijing China - Shanghai India - Bangalore Korea - Daegu Korea - Seoul Singapore Taiwan - Taipei Fax: 43-7242-2244-393 Denmark - Copenhagen France - Paris Germany - Dusseldorf Germany - Pforzheim Italy - Milan Italy - Venice Spain - Madrid Worldwide Sales and Service