15
Sense & Control Application Note Software Framework Revision 1.2, 2010-06-23 Preliminary PMA71xx/PMA51xx SmartLEWIS TM MCU RF Transmitter FSK/ASK 315/434/868/915 MHz Embedded 8051 Microcontroller with 10 bit ADC Embedded 125 kHz ASK LF Receiver

PMA71xx PMA51xx SoftwareFramework V1 2 - Infineon

  • Upload
    others

  • View
    0

  • Download
    0

Embed Size (px)

Citation preview

Page 1: PMA71xx PMA51xx SoftwareFramework V1 2 - Infineon

Sense & Control

Appl icat ion NoteSoftware FrameworkRevision 1.2, 2010-06-23Preliminary

PMA71xx/PMA51xxSmartLEWISTM MCU

RF Transmitter FSK/ASK 315/434/868/915 MHz Embedded 8051 Microcontroller with 10 bit ADC Embedded 125 kHz ASK LF Receiver

Page 2: PMA71xx PMA51xx SoftwareFramework V1 2 - Infineon

Edition 2010-06-23Published byInfineon Technologies AG81726 Munich, Germany© 2010 Infineon Technologies AGAll Rights Reserved.

Legal DisclaimerThe information given in this document shall in no event be regarded as a guarantee of conditions or characteristics. With respect to any examples or hints given herein, any typical values stated herein and/or any information regarding the application of the device, Infineon Technologies hereby disclaims any and all warranties and liabilities of any kind, including without limitation, warranties of non-infringement of intellectual property rights of any third party.

InformationFor further information on technology, delivery terms and conditions and prices, please contact the nearest Infineon Technologies Office (www.infineon.com).

WarningsDue to technical requirements, components may contain dangerous substances. For information on the types in question, please contact the nearest Infineon Technologies Office.Infineon Technologies components may be used in life-support devices or systems only with the express written approval of Infineon Technologies, if a failure of such components can reasonably be expected to cause the failure of that life-support device or system or to affect the safety or effectiveness of that device or system. Life support devices or systems are intended to be implanted in the human body or to support and/or maintain and sustain and/or protect human life. If they fail, it is reasonable to assume that the health of the user or other persons may be endangered.

Page 3: PMA71xx PMA51xx SoftwareFramework V1 2 - Infineon

PMA71xx/PMA51xx

Table of Contents

Preliminary Application Note 3 Revision 1.2, 2010-06-23Software Framework

Table of Contents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

List of Figures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

2 File structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62.1 Header files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72.1.1 Reg_PMA71xx_PMA51xx.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72.1.2 PMA71xx_PMA51xx_Library.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72.1.3 Misc_Functions.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72.1.4 RF_Functions.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72.2 Source files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72.2.1 STARTUP_PMA71xx_PMA51xx.A51 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72.2.2 Misc_Functions.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72.2.2.1 Xdata_CRC_Calc() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72.2.2.2 Xdata_CRC_Check() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72.2.3 Software_Framework.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82.2.4 Interrupt_Services.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82.2.5 RF_Functions.c . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82.2.5.1 RFInit() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82.2.5.2 RFTransmit() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82.3 Function Library file (PMA71xx_PMA51xx_Library.lib) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

3 PMA71xx/PMA51xx MCU specific features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93.1 Function Library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93.1.1 Code Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93.2 Wake-up and reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93.2.1 Code Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93.3 Watchdog Timer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103.4 Interval Timer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103.4.1 Code Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

4 Program flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

5 RF-Protocol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125.1 Payload of the RF-Transmission . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

Table of Contents

Page 4: PMA71xx PMA51xx SoftwareFramework V1 2 - Infineon

PMA71xx/PMA51xx

Preliminary Application Note 4 Revision 1.2, 2010-06-23Software Framework

Trademarks of Infineon Technologies AGABM™, BlueMoon™, CONVERGATE™, COSIC™, C166™, FALC™, GEMINAX™, GOLDMOS™, ISAC™,OMNITUNE™, OMNIVIA™, PROSOC™, SEROCCO™, SICOFI™, SIEGET™, SMARTi™, SmartLEWIS™,SMINT™, SOCRATES™, VINAX™, VINETIC™, VOIPRO™, X-GOLD™, XMM™, X-PMU™, XWAY™Other TrademarksMicrosoft®, Visio®, Windows®, Windows Vista®, Visual Studio®, Win32® of Microsoft Corporation. Linux® ofLinus Torvalds. FrameMaker®, Adobe® Reader™, Adobe Audition® of Adobe Systems Incorporated. APOXI®,COMNEON™ of Comneon GmbH & Co. OHG. PrimeCell®, RealView®, ARM®, ARM® Developer Suite™ (ADS),Multi-ICE™, ARM1176JZ-S™, CoreSight™, Embedded Trace Macrocell™ (ETM), Thumb®, ETM9™, AMBA™,ARM7™, ARM9™, ARM7TDMI-S™, ARM926EJ-S™ of ARM Limited. OakDSPCore®, TeakLite® DSP Core,OCEM® of ParthusCeva Inc. IndoorGPS™, GL-20000™, GL-LN-22™ of Global Locate. mipi™ of MIPI Alliance.CAT-iq™ of DECT Forum. MIPS™, MIPS II™, 24KEc™, MIPS32®, 24KEc™ of MIPS Technologies, Inc. TexasInstruments®, PowerPAD™, C62x™, C55x™, VLYNQ™, Telogy Software™, TMS320C62x™, Code ComposerStudio™, SSI™ of Texas Instruments Incorporated. Bluetooth® of Bluetooth SIG, Inc. IrDA® of the Infrared DataAssociation. Java™, SunOS™, Solaris™ of Sun Microsystems, Inc. Philips®, I2C-Bus® of Koninklijke PhilipsElectronics N.V. Epson® of Seiko Epson Corporation. Seiko® of Kabushiki Kaisha Hattori Seiko Corporation.Panasonic® of Matsushita Electric Industrial Co., Ltd. Murata® of Murata Manufacturing Company. Taiyo Yuden™of Taiyo Yuden Co., Ltd. TDK® of TDK Electronics Company, Ltd. Motorola® of Motorola, Inc. NationalSemiconductor®, MICROWIRE™ of National Semiconductor Corporation. IEEE® of The Institute of Electrical andElectronics Engineers, Inc. Samsung®, OneNAND®, UtRAM® of Samsung Corporation. Toshiba® of ToshibaCorporation. Dallas Semiconductor®, 1-Wire® of Dallas Semiconductor Corp. ISO® of the InternationalOrganization for Standardization. IEC™ of the International Engineering Consortium. EMV™ of EMVCo, LLC.Zetex® of Zetex Semiconductors. Microtec® of Microtec Research, Inc. Verilog® of Cadence Design Systems, Inc.ANSI® of the American National Standards Institute, Inc. WindRiver® and VxWorks® of Wind River Systems, Inc.Nucleus™ of Mentor Graphics Corporation. OmniVision® of OmniVision Technologies, Inc. Sharp® of SharpCorporation. Symbian OS® of Symbian Software Ltd. Openwave® of Openwave Systems, Inc. Maxim® of MaximIntegrated Products, Inc. Spansion® of Spansion LLC. Micron®, CellularRAM® of Micron Technology, Inc.RFMD® of RF Micro Devices, Inc. EPCOS® of EPCOS AG. UNIX® of The Open Group. Tektronix® of Tektronix,Inc. Intel® of Intel Corporation. Qimonda® of Qimonda AG. 1GOneNAND® of Samsung Corporation.HyperTerminal® of Hilgraeve, Inc. MATLAB® of The MathWorks, Inc. Red Hat® of Red Hat, Inc. Palladium® ofCadence Design Systems, Inc. SIRIUS Satellite Radio® of SIRIUS Satellite Radio Inc. TOKO® of TOKO Inc.,KEIL™The information in this document is subject to change without notice.Last Trademarks Update 2009-03-10

Revision History: 2010-06-23, Revision 1.2Previous Revision: 1.1Page Subjects (major changes since last revision)

6 This document is valid for software example revision V2.x

Page 5: PMA71xx PMA51xx SoftwareFramework V1 2 - Infineon

PMA71xx/PMA51xx

List of Figures

Preliminary Application Note 5 Revision 1.2, 2010-06-23Software Framework

Figure 1 File Structure of PMA71xx/PMA51xx Software Framework . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6Figure 2 Flowchart of the PMA71xx/PMA51xx Software Framework . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12Figure 3 RF-Frame with TDA523x Frame and Payload . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

List of Figures

Page 6: PMA71xx PMA51xx SoftwareFramework V1 2 - Infineon

PMA71xx/PMA51xx

Introduction

1 IntroductionThe PMA71xx/PMA51xx Software Framework is an example how software for PMA71xx/PMA51xx can bestructured. The available software example files include inline documentation and are developed to enable aneasy software development start and fast time to market. The software example files can be downloaded fromhttp://www.infineon.com/PMA_tooling. The installer for the source code of the PMA71xx/PMA51xx SoftwareFramework is called PMA_Software_Framework_V2.x.msi. The installer is included in the download package ofthe PMA Starter Kit as well as in the download package of the PMA Evaluation Kit. Furthermore moredocumentation of the source code done with doxygen will be copied to the specified location by thePMA_Software_Framework_V2.x.msi installer. The default path is PMA_Software_Framework_V2.x/html. Thedocumentation can be displayed with a standard browser by opening file index.html. The Software Framework hasalready implemented the following functionality:• Implementation of PMA71xx/PMA51xx startup file• Wake-up and reset handling• Interval Timer usage• Watchdog Timer handling• RF-Transmission• Interrupt handlingThis document describes the general file structure, specific features and the recommended program flow and iscompatible with source code revision 2.x (PMA_Software_Framework_V2.x.msi).

2 File structureThis chapter gives an overview over the structure of the PMA71xx/PMA51xx Software Framework and describesthe functionality implemented in the source files. Figure 1 shows how the files are linked.

Figure 1 File Structure of PMA71xx/PMA51xx Software Frameworkfile_structure.vsd

STARTUP_PMA71xx_PMA51xx.A51

CSEG AT 0x4000LJMP STARTUP 1...

Software _Framework .c

#include “Misc_Functions .h“#include “Reg _PMA71xx_PMA51xx.h“#include “PMA 71xx_PMA51xx_Library.h“#include “RF_Functions .h“...void main(void){…}

Misc_Functions .c#include "PMA71xx_PMA51xx_Library .h"#include "Reg_PMA71xx_PMA51xx.h“

void XData _CRC_Calc(..){...}...

RF_Functions.c

#include "Reg_PMA71xx_PMA51xx.h"#include "PMA71xx_PMA51xx_Library.h"

RFTransmit(..){…}...

PMA71xx_PMA51xx_Library.h…AES128Decrypt(..)AES128Encrypt(..)CalibrateIntervalTimer (..)...

Reg_PMA71xx_PMA51xx.h...sfr RFC = 0xEE; sfr RFD = 0x8E; sfr RFENC = 0xE7;...

Misc_Functions .h

XData_CRC_Calc();XData_CRC_Check ();

00H

FFH

RAM0000000000000000

...0000000000000000

PMA71xx_PMA51xx_Library.lib

RF_Functions .h

RFTransmit(..);RFInit ();

Interrupt_Services .c

pragma iv (0x4000 )#include “Reg _PMA71xx_PMA51xx.h“void ISR _ExternalInterrupt 0(void) interrupt 0 using 1{...}...

Preliminary Application Note 6 Revision 1.2, 2010-06-23Software Framework

Page 7: PMA71xx PMA51xx SoftwareFramework V1 2 - Infineon

PMA71xx/PMA51xx

File structure

2.1 Header filesIn the header files the interfaces to different modules are defined.

2.1.1 Reg_PMA71xx_PMA51xx.hThis is the register definition file for PMA71xx/PMA51xx. Here all Spezial Function Registers (SFRs) ofPMA71xx/PMA51xx are defined. This file has to be added to the project if direct SFR access is needed.

2.1.2 PMA71xx_PMA51xx_Library.hPMA71xx_PMA51xx_Library.h is the interface to the PMA71xx/PMA51xx Function Library. The prototypes of theFunction Library and some declarations for the RF-Transmission are defined here. This file has to be added to theproject together with PMA71xx_PMA51xx_Library.lib if the PMA71xx/PMA51xx Function Library is intended to beused.

2.1.3 Misc_Functions.hInterface to functions Xdata_CRC_Calc() and Xdata_CRC_Check().

2.1.4 RF_Functions.hInterface to functions RFInit() and RFTransmit().

2.2 Source filesThe source files include the implementation of the start up file, the functions defined in the header files, the main()function and the interrupt service routines.

2.2.1 STARTUP_PMA71xx_PMA51xx.A51This file is a modified copy of the standard 8051 startup file STARTUP.A51 delivered from KEILTM. It has to beadded to the project. If not the standard STARTUP.A51 is included by the linker. If PMA71xx/PMA51xx starts upfrom reset the whole idata memory 00H - FFH is initialized to 00H. The lower idata memory 00H - 7FH can bepowered during Power Down or Thermal Shutdown Mode by setting SFR bit CFG2.4 [PDLMB] to zero. If thePMA71xx/PMA51xx wakes up from Power Down or Thermal Shutdown State bit PDLMB is checked. If the loweridata memory is powered during Power Down or Thermal Shutdown State only the higher idata memory block 80H- FFH, otherwise the whole idata memory 00H - FFH, is initialized to 00H.Finally the stack pointer is initialized and a ljmp to main() is executed.

2.2.2 Misc_Functions.cThe functions Xdata_CRC_Calc() and Xdata_CRC_Check() are implemented within this file. A description of thefunctionality of each function can be found below.

2.2.2.1 Xdata_CRC_Calc()Calculates a CRC checksum over xdata content 00H - 0EH using the Library function CRC8Calculation() and storesthe CRC checksum into xdata 0FH. As the buffer passed to the Library function CRC8Calculation() must be inmemory space idata, the xdata content has to be copied into a idata buffer.

2.2.2.2 Xdata_CRC_Check()Checks if the CRC checksum of the xdata content is valid. Therefore the CRC checksum over the whole xdatacontent 00H - 0FH is calculated and must be 00H.

Preliminary Application Note 7 Revision 1.2, 2010-06-23Software Framework

Page 8: PMA71xx PMA51xx SoftwareFramework V1 2 - Infineon

PMA71xx/PMA51xx

File structure

2.2.3 Software_Framework.cThis file includes the main() function of the PMA71xx/PMA51xx Software Framework and is executed afterSTARTUP_PMA71xx_PMA51xx.A51. The xdata variables are defined here. They can be located to an absoluteposition in the xdata memory using the keyword _at_, therefore the definition must be global. Additionally somebit definitions are done to increase the readability of the code. In the main() function the wake-up bit DSR.1 [WUP]is checked to decide whether the PMA71xx/PMA51xx starts up from reset or with a wake-up event from PowerDown Mode. In case of a reset port 1 and port 3 direction, output and sensitivity registers are set according to the usage of thepins. All port pins, instead of PP2, are set to input and internal pull-down resistors are enabled. PP2 is set to inputand the internal pull-up resistor is enabled. Currently all interrupts are disabled but can be easily enabled by settingthe global interrupt enable and the appropriate interrupt enable bit. The wake-up mask registers WUM andExtWUM are used to enable or disable the internal and external wake-up sources. In the Software Framework theinternal wake-up for thermal shutdown and the external wake-up WU1 (PP2) is enabled (unmasked). Watchdog -and Interval Timer wake-up are always on in Normal, Programming and Debug Mode. After the wake-up settingsthe Interval Timer is calibrated. Therefore the system clock is switched to the external crystal clock to achievehigher accuracy. At the end of the reset routine the CRC checksum over the whole xdata content is calculated. Ifthe CRC checksum is not valid, the xdata variables are (re-)initialized to zero.If the PMA71xx/PMA51xx wakes up from Power Down or Thermal Shutdown State, the wake-up source ischecked. If a wake-up has been detected, the appropriate xdata counting variable is incremented, the CRCchecksum over xdata content 00H - 0EH is calculated and written to xdata memory at 0FH. In case of a WatchdogTimer - or thermal shutdown wake-up the PMA71xx/PMA51xx is reset to ensure a defined state of the SFRs. If anInterval Timer - or external WU1 wake-up occurred the Watchdog Timer is reset, the RF-Transmitter is initializedthrough RFInit(), the xdata variables are copied into an idata buffer and this buffer is transmitted over RF by callingRFTransmit(). After the transmission the PMA71xx/PMA51xx is set into Power Down Mode to save energy andwaits for the next wake-up event. The check for all existing wake-up flags is already implemented. To be able touse one of the currently disabled (masked) wake-up sources, the wake-up source has to be enabled and the wake-up has to be handled.

2.2.4 Interrupt_Services.cCurrently no interrupt is enabled. To be able to use an interrupt the appropriate enable bits inSoftware_Framework.c has to be set. In Interrupt_Services.c all interrupt service routines are defined and have tobe implemented if an interrupt should be used. There is a lot of inline documentation within this file which describeswhich bits have to be set to enable every single interrupt.

2.2.5 RF_Functions.cThe functions of RFInit() and RFTransmit() are implemented in RF_Functions.c.

2.2.5.1 RFInit()First of all a variable of the struct RF_Config, see PMA71xx_PMA51xx_Library.h, is defined and initialized. Thenthe Library function InitRF() is called to set the appropriate values to all SFRs needed for the RF-Transmission. Adetailed description of each element of the struct RF_Config can be found in [1].

2.2.5.2 RFTransmit()The RF-Transmission is done by this function. This function is used to generate the RF-Framing which is requiredby the TDA523x receiver. The RF-Frame is described in detail in Chapter 5.

2.3 Function Library file (PMA71xx_PMA51xx_Library.lib)This is the Function Library where all functions defined in PMA71xx_PMA51xx_Library.h are implemented.

Preliminary Application Note 8 Revision 1.2, 2010-06-23Software Framework

Page 9: PMA71xx PMA51xx SoftwareFramework V1 2 - Infineon

PMA71xx/PMA51xx

PMA71xx/PMA51xx MCU specific features

3 PMA71xx/PMA51xx MCU specific featuresThe PMA71xx/PMA51xx MCU supports some specific features that are not standard within 8051 micro controllersand which assist the user with the software development. These are listed below and described in the followingchapters:• PMA71xx/PMA51xx Function Library• Wake-up and reset• Watchdog Timer• Interval Timer

3.1 Function LibraryThe PMA71xx/PMA51xx Function Library is a set of optimized functions developed by Infineon which make it veryeasy for the user to develop a software application for the PMA71xx/PMA51xx. A detailed description of everyfunction implemented in the PMA71xx/PMA51xx Function Library can be found in [1]. By using aPMA71xx/PMA51xx Function Library function the user does not need to set every single bit in a couple of SFRsto get the intended functionality. To initialize the RF-Transmission for example about 85 bits in 11 SFRs have tobe set. This can be simply done by only one PMA71xx/PMA51xx Function Library function, InitRF(..), as shown inbelow example.

3.1.1 Code ExampleTo set up the RF-Transmitter a variable of struct RF_Config, which is defined in PMA71xx_PMA51xx_Library.h,is initialized and the PMA71xx/PMA51xx Function Library function InitRF(..) is called using this variable asparameter.// declare and initialize a variable of struct RF_Config

struct RF_Config idata myRF_Config;myRF_Config.Quiescent = 0;myRF_Config.IntMask = 0;myRF_Config.DutyControl = DUTY_OFF;myRF_Config.XcapShort = DISABLE;myRF_Config.Encoding = MANCHESTER;myRF_Config.dataLength = 7;myRF_Config.DutyCycle = DUTY_27;myRF_Config.Modulation = ASK;myRF_Config.Invert = NO_INVERT;myRF_Config.Frequency = RF_315MHZ;myRF_Config.OutStages = STAGE_3;myRF_Config.xtal0 = 0x28;myRF_Config.xtal1 = 0x11;myRF_Config.baudrate = 9600;

// call Library function InitRF(..)

InitRF(&myRF_Config);

3.2 Wake-up and resetAfter wake-up or reset the PMA71xx/PMA51xx starts program execution at code address 4000H. To decidewhether a wake-up or a reset has occurred the following code example could be used.

3.2.1 Code ExampleThe SFR bit DSR.1 [WUP] signals if there was a wake-up. If this bit is not set the PMA71xx/PMA51xx must hasstarted up from reset. The PMA71xx/PMA51xx Function Library function PowerDown() sets thePMA71xx/PMA51xx into Power Down Mode to save energy.

// Include PMA71xx/PMA51xx Function Library#include "PMA71xx_PMA51xx_Library.h"// Include the PMA71xx/PMA51xx register file (DSR is defined here)

Preliminary Application Note 9 Revision 1.2, 2010-06-23Software Framework

Page 10: PMA71xx PMA51xx SoftwareFramework V1 2 - Infineon

PMA71xx/PMA51xx

PMA71xx/PMA51xx MCU specific features

#include "Reg_PMA71xx_PMA51xx.h"#define BIT_WUP 0x02

void main(void){// Decision: reset or wake-up entry:// ================================if ((DSR & BIT_WUP)== 0) {

// Reset entry:// ============

}else {

// Wake-up entry:// =============

}// Set PMA71xx/PMA51xx into Power Down Mode (Function Library call)PowerDown();

}

3.3 Watchdog TimerFor operation security a Watchdog Timer is available. The Watchdog Timer represents an up-counter that isstarted with value 0 and counted up by the 2kHz RC-LP clock. If the Watchdog Timer overflows after approximately1 s, it causes the wake-up unit to generate a reset pulse in order to reset the system. Thus infinite software loopscaused by an unstable system are broken up.The Watchdog Timer is automatically reset at wake-up- or Idle events.Note: The up-counter has to be reset periodically by setting the SFR bit CFG2.1 [WDRES] to avoid the Watchdog

Timer reset event. The Watchdog Timer mask bit WUM.7 [WDog] is only applicable in Test Mode. In Normal Mode, the Watchdog Timer cannot be disabled. In Programming and Debug Mode, the firmware handler resets the Watchdog Timer in its main polling loop (polling for I2C commands).

3.4 Interval TimerThe Interval Timer is responsible to wake up the PMA71xx/PMA51xx from POWER DOWN state after a specifiedtime interval. In Normal Mode the Interval Timer and the corresponding wake-up is always enabled. As shown inChapter 3.4.1 the Interval Timer can be configured easily using the PMA71xx/PMA51xx Function Library functionCalibrateIntervalTimer(..).

3.4.1 Code ExampleIn the reset entry the Interval Timer is calibrated with the PMA71xx/PMA51xx Function Library functionCalibrateIntervalTimer(..). To get higher accuracy an external crystal oscillator shall be used. In the wake-up entry the wake-up source is checked for Interval Timer wake-up. The handling of the Interval Timerwake-up has to be implemented.The PMA71xx/PMA51xx Function Library function PowerDown() sets the PMA71xx/PMA51xx into Power DownMode to save energy.// Include PMA71xx/PMA51xx Function Library#include "PMA71xx_PMA51xx_Library.h"// Include the PMA71xx/PMA51xx register file (DSR is defined here)#include "Reg_PMA71xx_PMA51xx.h"#define BIT_WUP 0x02#define BIT_IT 0x01

void main(void){unsigned long idata Xtal_Frequency_2 = 9040000;unsigned char WU_Frequency = 10;

// Decision: reset or wake-up entry:// ================================if ((DSR & BIT_WUP)== 0) {

// Reset entry:// ============

Preliminary Application Note 10 Revision 1.2, 2010-06-23Software Framework

Page 11: PMA71xx PMA51xx SoftwareFramework V1 2 - Infineon

PMA71xx/PMA51xx

Program flow

// Interval Timer configuration: // ============================// Dependent on accuracy criteria as well as time and voltage drift// recalibration is recommended.

// Switch from 12MHz Hi RC oscillator to external crystal// to get higher accuracy. (Function Library call)Switch2XTAL();

// Interval Timer is calibrated to wake up the PMA71xx/PMA51xx every 100 ms (f = 10Hz)// (Function Library call)CalibrateIntervalTimer(WU_Frequency, &Xtal_Frequency_2);

}else {

// Wake-up entry:// =============

// Interval Timer wake-up (be careful WUF is clear on read!)if (WUF & BIT_IT) {

// .. handle Interval Timer wake-up}

}// Set PMA71xx/PMA51xx into Power Down Mode (Function Library call)PowerDown();

}

4 Program flowFigure 2 on Page 12 shows a flowchart of the Software Framework.The PMA71xx/PMA51xx starts program execution within the startup file. After RAM initialization the wake-up flagin SFR DSR.1 [WUP] is checked to decide whether the PMA71xx/PMA51xx starts up from a reset or because ofa wake-up event. If PMA71xx/PMA51xx starts up from reset all used modules are initialized by the corresponding SFR. To be ableto use the external wake-up WU1 Pin PP2 is configured as input and the appropriate wake-up is enabled. Currentlyall interrupts are disabled and can be easily activated by enabling the global and the according interrupt. TheInterval Timer is calibrated and a CRC checksum is calculated over the XRAM. This checksum is used to controlif the XRAM data is still valid after a reset triggered by the Watchdog Timer or a thermal shutdown. Finally thePMA71xx/PMA51xx is set into Power Down Mode to save energy and waits for a wake-up event.If PMA71xx/PMA51xx starts up from Power Down Mode with a wake-up event, the wake-up source is checked.Four wake-up sources are handled by the Software Framework. This are the Watchdog Timer -, the thermalshutdown -, the Interval Timer -, and the external WU1 wake-up. A counting variable is stored in the XRAM forevery implemented wake-up. These variables are incremented in the appropriate wake-up service routine and aCRC checksum is calculated. After Watchdog Timer - and thermal shutdown wake-up a software reset is triggeredto ensure that all SFRs have a predefined state. After Interval Timer - or external WU1 wake-up the RF-Transmitteris initialized, the XRAM content is transmitted via RF and the PMA71xx/PMA51xx is set into Power Down Mode.

Preliminary Application Note 11 Revision 1.2, 2010-06-23Software Framework

Page 12: PMA71xx PMA51xx SoftwareFramework V1 2 - Infineon

PMA71xx/PMA51xx

RF-Protocol

Figure 2 Flowchart of the PMA71xx/PMA51xx Software Framework

5 RF-ProtocolThe RF-Transmission of the PMA71xx/PMA51xx Software Framework is designed to be compatible with TDA523xreceivers. Therefore a special RF-Protocol has to be used.The following settings are used for RF-Transmission (set in RFInit(), see RF_Functions.c):• Encoding: Manchester• Modulation: FSK• Baud rate: 9600 bps• Frequency: 434 MHz

Flowchart.vsd

Init wake-ups

Reset or Wake-up

PowerDown()

Check wake-up source

Init RF-Tx and transmit RF-

Frame

Init counter variables in

battery buffered XRAM

Calibrate Interval Timer

Pin configuration

Interrupt settings

Increment thermal

shutdown wake-up counter

Watchdog timerwake-up

Thermal Shutdown wake-up

Increment external WU1

wake-up counter

External WU1(PP2)

Reset PMA71xx/PMA51xx

Increment watchdog timer wake-up counter

Calculate CRC over XRAM

Calculate CRC over XRAM

Calculate CRC over XRAM

Check XRAM CRC

CRCvalid ?

NO

YES NO

YES

NO

YES

Reset PMA71xx/PMA51xx

NO

YES

Increment Interval Timer

wake-up counter

Interval Timerwake-up

Calculate CRC over XRAM

YES

Wake-up Reset

NO

RAM initialization in startup file

Preliminary Application Note 12 Revision 1.2, 2010-06-23Software Framework

Page 13: PMA71xx PMA51xx SoftwareFramework V1 2 - Infineon

PMA71xx/PMA51xx

RF-Protocol

The RF-Frame starts with a RUNIN sequence of 8 manchester coded data bits (16 chips) which are used by theTDA523x receiver for internal filter setting and frequency adjustment. Then the 16 chips long TSI (Telegram StartIdentifier) follows, which is used to synchronize the frame and detect the exact start of a data frame (payload). Todetect the EOM (End of Message) a manchester violation (two 1B chips) is sent.

5.1 Payload of the RF-TransmissionThe payload of the RF-Transmission is 16 bytes long and consists of simple up counter values for different wake-ups. These wake-ups are Watchdog Timer -, Interval Timer -, thermal shutdown - and external WU1 wake-up.Additionaly there is one byte (XDB) from the xdata memory availalbe which is currently not used, but alsotransmitted via RF. Every time one of these wake-ups occurs the appropriate counter variable is incremented andan RF-Transmission is started. The whole RF-Frame including the TDA523x-Frame and the payload is shown inFigure 3 on Page 13.

Figure 3 RF-Frame with TDA523x-Frame and payload

rf_frame.vsd

Bits

Chips 0 1

0

RUNIN TSI

1 10 1

0

0 1

0

0 1

0

0 1

0

0 1

0

0 1

0

0 1

0

0 1

0

0 1

0

0 1

0

1 0

1

Payload

WDWU

32 bits 32 bits 32 bits 16 bits 8 bits

ITWU TMWU EWU1 CRC

EOM

RUNIN .. Run in sequence (synchronisation)

TSI .. Telegram Start Identifier

EWU1 .. External WU1 wake-up counter

WDWU .. Watchdog Timer wake-up counter

ITWU .. Interval Timer wake-up counter

TMWU .. Thermal Shutdown wake-up counter

CRC .. checksum over xdata[0H:EH]

EOM .. End of Message

0 1

0

0 1

0

0 1

0

0 1

0 XDB

8 bits

XDB .. xdata byte

Preliminary Application Note 13 Revision 1.2, 2010-06-23Software Framework

Page 14: PMA71xx PMA51xx SoftwareFramework V1 2 - Infineon

PMA71xx/PMA51xx

References

Preliminary Application Note 14 Revision 1.2, 2010-06-23Software Framework

References[1] PMA Function Library Guide

Page 15: PMA71xx PMA51xx SoftwareFramework V1 2 - Infineon

Published by Infineon Technologies AG

w w w . i n f i n e o n . c o m