38
Document Number: SMACRM Rev. 1.2 04/2005 Simple Media Access Controller (SMAC) User’s Guide

Simple Media Access Controller (SMAC)read.pudn.com/.../sourcecode/.../SMAC-manual.pdf · Document Number: SMACRM Rev. 1.2 04/2005 Simple Media Access Controller (SMAC) User’s Guide

  • Upload
    others

  • View
    12

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Simple Media Access Controller (SMAC)read.pudn.com/.../sourcecode/.../SMAC-manual.pdf · Document Number: SMACRM Rev. 1.2 04/2005 Simple Media Access Controller (SMAC) User’s Guide

Document Number: SMACRMRev. 1.204/2005

Simple Media Access Controller(SMAC)

User’s Guide

Page 2: Simple Media Access Controller (SMAC)read.pudn.com/.../sourcecode/.../SMAC-manual.pdf · Document Number: SMACRM Rev. 1.2 04/2005 Simple Media Access Controller (SMAC) User’s Guide

How to Reach Us:

Home Page:www.freescale.com

E-mail:[email protected]

USA/Europe or Locations Not Listed:Freescale SemiconductorTechnical Information Center, CH3701300 N. Alma School RoadChandler, Arizona 85224+1-800-521-6274 or [email protected]

Europe, Middle East, and Africa:Freescale Halbleiter Deutschland GmbHTechnical Information CenterSchatzbogen 781829 Muenchen, Germany+44 1296 380 456 (English)+46 8 52200080 (English)+49 89 92103 559 (German)+33 1 69 35 48 48 (French)[email protected]

Japan:Freescale Semiconductor Japan Ltd.HeadquartersARCO Tower 15F1-8-1, Shimo-Meguro, Meguro-ku,Tokyo 153-0064, Japan0120 191014 or +81 3 5437 [email protected]

Asia/Pacific:Freescale Semiconductor Hong Kong Ltd.Technical Information Center2 Dai King StreetTai Po Industrial EstateTai Po, N.T., Hong Kong+800 2666 [email protected]

For Literature Requests Only:Freescale Semiconductor Literature Distribution CenterP.O. Box 5405Denver, Colorado 802171-800-521-6274 or 303-675-2140Fax: [email protected]

Information in this document is provided solely to enable system and software implementers to use Freescale Semiconductor products. There are no express or implied copyright licenses granted hereunder to design or fabricate any integrated circuits or integrated circuits based on the information in this document.Freescale Semiconductor reserves the right to make changes without further notice to any products herein. Freescale Semiconductor makes no warranty, representation or guarantee regarding the suitability of its products for any particular purpose, nor does Freescale Semiconductor assume any liability arising out of the application or use of any product or circuit, and specifically disclaims any and all liability, including without limitation consequential or incidental damages. “Typical” parameters that may be provided in Freescale Semiconductor data sheets and/or specifications can and do vary in different applications and actual performance may vary over time. All operating parameters, including “Typicals”, must be validated for each customer application by customer’s technical experts. Freescale Semiconductor does not convey any license under its patent rights nor the rights of others. Freescale Semiconductor products are not designed, intended, or authorized for use as components in systems intended for surgical implant into the body, or other applications intended to support or sustain life, or for any other application in which the failure of the Freescale Semiconductor product could create a situation where personal injury or death may occur. Should Buyer purchase or use Freescale Semiconductor products for any such unintended or unauthorized application, Buyer shall indemnify and hold Freescale Semiconductor and its officers, employees, subsidiaries, affiliates, and distributors harmless against all claims, costs, damages, and expenses, and reasonable attorney fees arising out of, directly or indirectly, any claim of personal injury or death associated with such unintended or unauthorized use, even if such claim alleges that Freescale Semiconductor was negligent regarding the design or manufacture of the part.

Freescale™ and the Freescale logo are trademarks of Freescale Semiconductor, Inc. All other product or service names are the property of their respective owners.

© Freescale Semiconductor, Inc. 2004, 2005. All rights reserved.

Page 3: Simple Media Access Controller (SMAC)read.pudn.com/.../sourcecode/.../SMAC-manual.pdf · Document Number: SMACRM Rev. 1.2 04/2005 Simple Media Access Controller (SMAC) User’s Guide

SMAC User’s Guide, Rev. 1.2

Freescale Semiconductor 1

ContentsAbout This Book

Audience . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3Organization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3Revision History . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4Definitions, Acronyms, and Abbreviations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4References. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

Chapter 1 SMAC Introduction

1.1 SMAC Features. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-11.2 SMAC Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-21.3 Required MCU Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-31.4 Block Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-31.5 SMAC 4.1 Primitives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-41.5.1 MCPSDataRequest . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-41.5.2 MCPSDataIndication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-51.5.3 MLMEHibernateRequest . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-61.5.4 MLMEWakeRequest . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-71.5.5 MLMESetChannelRequest . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-71.5.6 MLMERXEnableRequest . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-81.5.7 MLMERXDisableRequest . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-91.5.8 MLMESetMC13192ClockRate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-91.5.9 MLMEEnergyDetect . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-101.5.10 MLMEMC13192SoftReset. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-101.5.11 MLMEMC13192XtalAdjust. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-111.5.12 MLMELinkQuality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-111.5.13 MLMESetMC13192TmrPrescale . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-121.5.14 MLMEMC13192FEGainAdjust . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-121.5.15 MLMEDozeRequest . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-131.5.16 MLMEMC13192PAOutputAdjust . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-141.5.17 MLMEGetRficVersion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-151.5.18 MLMETestMode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-151.5.19 MLMEMC13192ResetIndication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-161.6 Low Noise Amplifier (LNA) and Antenna Switch Support . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-16

Chapter 2 SMAC Data Types

2.1 Fundamental data types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-12.2 tTxPacket . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-12.3 tRxPacket . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-2

Page 4: Simple Media Access Controller (SMAC)read.pudn.com/.../sourcecode/.../SMAC-manual.pdf · Document Number: SMACRM Rev. 1.2 04/2005 Simple Media Access Controller (SMAC) User’s Guide

SMAC User’s Guide, Rev. 1.2

2 Freescale Semiconductor

Chapter 3 Using the Embedded Bootloader

3.1 Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-1

Appendix A Migrating from SMAC 4.0 to SMAC 4.1

Appendix B SMAC C-coding Standard

Appendix C Restoring the Embedded Bootloader

Page 5: Simple Media Access Controller (SMAC)read.pudn.com/.../sourcecode/.../SMAC-manual.pdf · Document Number: SMACRM Rev. 1.2 04/2005 Simple Media Access Controller (SMAC) User’s Guide

SMAC User’s Guide, Rev. 1.2

Freescale Semiconductor 3

About This BookThis guide provides a detailed description of the Simple Media Access Controller (SMAC).

AudienceThis document is intended for application developers building 802.15.4/ZigBee applications.

OrganizationThis document is organized into 3 chapters and 3 appendices.Chapter 1 Introduction - This chapter gives a brief introduction to the ANSI C-based code

stack that is provided as source code.Chapter 2 SMAC Data Types - This chapter details the SMAC custom data types.Chapter 3 Using the Embedded Bootloader - This chapter describes how to download an

application to a board using the Embedded Bootloader.Appendix A Migrating from SMAC 4.0 to SMAC 4.1- This appendix describes how to

migrate a project from SMAC 4.0 to SMAC 4.1.Appendix B SMAC C-coding Standards - This appendix shows the SMAC C-coding

convention used in the SMAC Stack.Appendix C Restoring The Embedded Bootloader - This appendix shows how to restore the

Embedded Bootloader to the DIG-528, DIG-536, and Axiom GB60 Evaluation Boards.

Revision HistoryThe following table summarizes revisions to this document since the previous release (Rev. 1.1).

Revision History

Location Revision

Entire Document Added 3 Appendices. Rewrote for SMAC version 4.1 software.

Page 6: Simple Media Access Controller (SMAC)read.pudn.com/.../sourcecode/.../SMAC-manual.pdf · Document Number: SMACRM Rev. 1.2 04/2005 Simple Media Access Controller (SMAC) User’s Guide

SMAC User’s Guide, Rev. 1.2

4 Freescale Semiconductor

ConventionsThis document uses the following notational conventions:

• Courier monospaced type indicate commands, command parameters, code examples, expressions, datatypes, and directives.

• Italic type indicates replaceable command parameters.• All source code examples are in C.

Definitions, Acronyms, and AbbreviationsThe following list defines the acronyms and abbreviations used in this document.BDM debugger A debugger using the BDM interface for communication with the MCU. An

example is the P&E BDM Multilink debugger for HCS08.BDM Background Debug ModuleEVB Evaluation Boards - this term covers the 13192-EVB and 13192-SARD boards.EVK Evaluation KitGUI Graphical User InterfaceMAC Medium Access ControlMCU MicroController UnitNVM None-Volatile MemoryPC Personal ComputerPCB Printed Circuit BoardS19 'S19' is the file extension used for the Freescale binary image format. The S19 file

encapsulates the binary image as a list of ASCII records. Each record contains a length -, address -, data - and checksum field. The 16 bit address field allows a memory space for up to 64 KB. The S19 can be generated with Metrowerks CodeWarrior IDE and is the product from the linking process. S19 does not contain additional information to a debugger (where to look for source files).

Safe Mode Boot The Embedded Bootloader boots up using safe default system values.HIWAVE P&E HCS08 debugger GUI.CPROG P&E HCS08 flash programming tool called from HIWAVE. The tool is also

available in a command line version where scripts can be made.

ReferencesThe following sources were referenced to produce this book:

[1] Freescale 802.15.4 MAC/PHY Software Reference Manual (802154MPSRM)

[2] Zigbee.hlp(see Test Tool installation directory .\help)

Page 7: Simple Media Access Controller (SMAC)read.pudn.com/.../sourcecode/.../SMAC-manual.pdf · Document Number: SMACRM Rev. 1.2 04/2005 Simple Media Access Controller (SMAC) User’s Guide

SMAC User’s Guide, Rev. 1.2

Freescale Semiconductor 1-1

Chapter 1 SMAC IntroductionThe SMAC is a simple ANSI C based code stack available as sample source code, which can be used to develop proprietary RF transceiver applications using the MC1319x integrated circuit. The SMAC was built to work with any HCS08 MCU with an SPI, but it can easily be adapted to most any processor core.

Some sample applications (Accelerometer, Lighting Demo, Packet Error Rate, Range Demo Plus, Wireless UART, and a Simple Network Demo) as well as a SMAC Application Template are included.

1.1 SMAC Features• Compact footprint:

— 2K FLASH— 10 bytes (+ maximum packet length) RAM— As low as 16kHz bus clock

• Can be used to demonstrate coin cell operation for a remote control• MC13192 v2.x compatible• Very-low power, proprietary, bi-directional RF communication link• ANSI C source code targeted for the HCS08 core and ported to almost any CPU core (including

4-bit)• Low priority IRQ• Easy to use sample applications included• Well commented code• Metrowerks CodeWarrior Experimental edition for support• Use of MC1319x packet transfer for MCU resources saving:

— Up to 123 bytes of Payload Data in a single packet— Automatic Frame Check Sequence (FCS) for error detection

• Automatic append of 2 Code Bytes to every packet in order to ignore other protocol’s packets and to let other protocols ignore SMAC packets. Figure 1-1 shows the packet structure.

• Implementation of the MC1319x hidden registers initialization as recommended in the MC13192/93 Reference Manual (MC13192RM) and MC13191 Reference Manual (MC13191RM).

• Doze Request has an optional automatic wakeup• The file structure supports easy porting of SMAC to other architectures

Page 8: Simple Media Access Controller (SMAC)read.pudn.com/.../sourcecode/.../SMAC-manual.pdf · Document Number: SMACRM Rev. 1.2 04/2005 Simple Media Access Controller (SMAC) User’s Guide

SMAC Introduction

SMAC User’s Guide, Rev. 1.2

1-2 Freescale Semiconductor

Figure 1-1. SMAC Packet Structure

1.2 SMAC InstallationUnzip the SMAC into the SMAC4.1 directory along with the other application demonstration programs. Both the source files and libraries are included for the SMAC. Most applications use the SMAC libraries and are automatically included when the application is compiled. Figure 1-2 shows the basic folder structure.

Figure 1-2. SMAC Folder Structure

NOTEThe folder structure in version 4.1 is different than in version 4.0. Changes should be made for projects created using SMAC Version 4.0. For more information, refer to Appendix A, Migrating from SMAC 4.0 to SMAC 4.1.

The “Demo Projects” folders contain the needed files for a specific sample application. The “Supporting files” folders contain some general or common files needed for different applications. For example, the “common” folder in the “apps” directory has some .c and .h files used in all the applications. The “SMAC(Sources)” folder contains the SMAC source code that can be used from different platforms.

There are two “supporting projects”:1. smac2. target

These projects are used to create the libraries needed by the applications.

Page 9: Simple Media Access Controller (SMAC)read.pudn.com/.../sourcecode/.../SMAC-manual.pdf · Document Number: SMACRM Rev. 1.2 04/2005 Simple Media Access Controller (SMAC) User’s Guide

SMAC Introduction

SMAC User’s Guide, Rev. 1.2

Freescale Semiconductor 1-3

Each application contains the SMAC project as a sub-project. Changes in the SMAC are reflected in all applications on the next compile.

NOTEThe Special Edition license for CodeWarrior will not be enough compile them. Because of that, certain applications have versions compatible with such a license and have the “_SE” suffix (For example, there is an Accelerometer V2.mcp and also an Accelerometer V2_SE.mcp).

The main difference between both files is that the SE doesn’t include the SMAC or the TARGET projects as subprojects. The other file does include those projects, and each time the user compiles the application, the SMAC and TARGET projects are also compiled and new versions of the libraries are created.

To open a project, users need to open their version of CodeWarrior for HC(S)08 and from its GUI open the required mcp file (which is the project file):\SMAC4.1\S08\apps\Accel_V2.0\3.1 Project\\SMAC4.1\S08\apps\Wireless Uart\3.1\\SMAC4.1\S08\apps\SMAC Application Template\3.1\\SMAC4.1\S08\apps\Range demo Plus\Range Demo Plus RX\3.1\\SMAC4.1\S08\apps\Range demo Plus\Range Demo Plus TX\3.1\\SMAC4.1\S08\apps\Packet Error Rate with ACKs (Min TX Power)\3.1\\SMAC4.1\S08\apps\Lighting Demo\Lighting_demo_controller\3.1\\SMAC4.1\S08\apps\Lighting Demo\Lighting_demo_device\3.1\

After the project is loaded, it is then flashed into the HCS08 chip using a Background Debug Module (BDM) programmer. The debugger must be set in “In-Circuit Debug/Programming” mode to flash the HCS08. This is accomplished by selecting the green arrow (or the ant icon) on the menu bar. This places the Metrowerks software in the Program/Debug mode and it will begin to download the MCU. For more information regarding the Debugger, refer to Metrowerks CodeWarrior Documentation located on the CD.

NOTEIf no BDM is available, the user can also flash the boards. Refer to Chapter 3, Using the Embedded Bootloader, for more information.

1.3 Required MCU Resources• Internal MCU clock (optional)• SPI module (or optionally, three GPIOs)• The SMAC 4.1 hardware interface normally uses four GPIOs (Reset, RTXEN, ATTN and CE) but

can be configured to use as few as three GPIOs or as many as seven GPIOs.• IRQ any priority. Keyboard IRQ can be used instead

1.4 Block DiagramFigure 1-3 shows the SMAC block diagram.

Page 10: Simple Media Access Controller (SMAC)read.pudn.com/.../sourcecode/.../SMAC-manual.pdf · Document Number: SMACRM Rev. 1.2 04/2005 Simple Media Access Controller (SMAC) User’s Guide

SMAC Introduction

SMAC User’s Guide, Rev. 1.2

1-4 Freescale Semiconductor

Figure 1-3. SMAC Block Diagram

1.5 SMAC 4.1 PrimitivesThe following sections provide a detailed description of the SMAC primitives.

1.5.1 MCPSDataRequestThis data primitive is used to send a packet. It is used in the following manner:

Prototype

UINT8 MCPSDataRequest(tTxPacket *psTxPacket);

Arguments

tTxPacket *: Packet to transmit

Returns

{SUCCESS}

Usage• Load the packet into a tTxPacket variable. In the examples called “gsTxPacket”.• Application calls MCPSDataRequest(&gsTxPacket).• Data is transmitted by MC1319x.• MCPSDataRequest() returns {SUCCESS}.

This command places the MCU into WAIT until the MC1319x is finished transmitting the packet. As a result, the MCU is blocked and the user application halts until the packet is transmitted.

NOTEThe only possible return value of this function is SUCCESS.

Page 11: Simple Media Access Controller (SMAC)read.pudn.com/.../sourcecode/.../SMAC-manual.pdf · Document Number: SMACRM Rev. 1.2 04/2005 Simple Media Access Controller (SMAC) User’s Guide

SMAC Introduction

SMAC User’s Guide, Rev. 1.2

Freescale Semiconductor 1-5

1.5.2 MCPSDataIndicationThis callback function (a function that is located within the user’s application code and is needed by the SMAC) needs to be placed in the application. This allows the SMAC to call this function when data is received by the MC1319x to be processed by the application. It is used as follows:

Prototype

void MCPSDataIndication(tRxPacket *gsRxPacket);

Arguments

tRxPacket *:A pointer to a variable where the received packet will be placed

Returns

void

Usage

Turn on the MC1319x receiver by using the MLMERXEnableRequest call. When the MC1319x receives data, the lower levels will call MCPSDataIndication. The data, status, and the number of bytes received will be contained in the tRxPacket structure. In the sample applications, the variable is gsRxPacket.

The application will then check the status field of gsRxPacket to determine if the packet received is:• SUCCESS. A good packet.• Application reads the number of bytes received via the gsRxPacket.u8DataLength field.• Application will then parse the data in the gsRxPacket.pu8Data field.• TIMEOUT. A timeout occurred. It is used when the receiver is turned on for a specific amount of

time. See MLMERXEnableRequest.• OVERFLOW. A packet greater than the requested number of bytes has been received.

Notes

The following code is an example that uses this function. It is called once a packet is received, then it verifies whether it is a successful reception or a timeout. If it was a successful reception, it shows the data payload through the SCI. And if it was a TIMEOUT, it leads the application to the TIMEOUT_STATE.

void MCPSDataIndication(tRxPacket *gsRxPacket) { if (gsRxPacket->u8Status == SUCCESS) { /* Packet received */ SCITransmitStr(&gsRxPacket->pu8Data[0]); gi8AppStatus = TRANSMIT_ACK; } if (gsRxPacket->u8Status == TIMEOUT) { /* Received TIMEOUT */ gi8AppStatus = TIMEOUT_STATE; } }

Page 12: Simple Media Access Controller (SMAC)read.pudn.com/.../sourcecode/.../SMAC-manual.pdf · Document Number: SMACRM Rev. 1.2 04/2005 Simple Media Access Controller (SMAC) User’s Guide

SMAC Introduction

SMAC User’s Guide, Rev. 1.2

1-6 Freescale Semiconductor

1.5.3 MLMEHibernateRequestThis call places the MC1319x into Hibernate mode. Refer to the MC13192/93 Reference Manual (MC13192RM) and MC13191 Reference Manual (MC13191RM) for further information on the operation modes.

Prototype

UINT8 MLMEHibernateRequest(void);

Arguments

None

Returns

{SUCCESS}

Usage

When the MC1319x is in Hibernate mode, it disables its Clock Output (CLKO). If the MCU is using this signal as a clock source, the user should first switch to Internal clock and then make the MLMEHibernateRequest() call to place the MC1319x into hibernate mode. This way, the MCU continues to operate and can then be debugged.

Notes

Users make a call to MLMEWakeRequest () to bring the MC1319x out of hibernate and back into normal mode. Once in normal mode, users can switch to the external clock source provided.

Refer to the following example:for (;;) { switch (gi8AppStatus) { case INITIAL_STATE: gi8AppStatus = RUNNING_STATE; /* Change to Running State */ break; case RUNNING_STATE: gi8AppStatus = HIBERNATE_STATE; /* Change to Hibernate State */ UseMcuClock();/* Change to Internal Clock */ MLMEHibernateRequest(); /* Send the MC1319x to Hibernate mode */ LED2=0; LED3=1; break; case HIBERNATE_STATE: gi8AppStatus = RUNNING_STATE; /* Change to Running State */ MLMEWakeRequest(); /* Set the MC1319x to Idle mode */ UseExternalClock(); /* Change to External Clock */ LED2=1; LED3=0; break; default: break; } LED4 = ~LED4;

Page 13: Simple Media Access Controller (SMAC)read.pudn.com/.../sourcecode/.../SMAC-manual.pdf · Document Number: SMACRM Rev. 1.2 04/2005 Simple Media Access Controller (SMAC) User’s Guide

SMAC Introduction

SMAC User’s Guide, Rev. 1.2

Freescale Semiconductor 1-7

Wait(); /* A simple wait routine */ }

1.5.4 MLMEWakeRequestThis primitive brings the MC1319x out of low power mode.

Prototype

UINT8 MLMEWakeRequest(void);

Arguments

None

Returns

{SUCCESS, ERROR}

Usage

Call this function directly when the MC1319x is in hibernate or doze mode.

Notes

SUCCESS is returned if the MC1319x was either in Hibernate or Doze mode.

ERROR is returned if the MC1319x was neither in Hibernate nor Doze mode.

For an example on this primitive, refer to function MLMEHibernateRequest().

1.5.5 MLMESetChannelRequestThis sets the actual frequency that the MC1319x transmits and receives on.

Prototype

UINT8 MLMESetChannelRequest(UINT8 u8Channel);

Arguments

UINT8 : An 8 bit value that represents the requested channels. Values 0-15 are expected.

Returns

{SUCCESS, ERROR}

Usage

Simply call MLMESetChannelRequest (channel requested).

Notes

Channels 0-15 are expected.

SUCCESS is returned if a correct channel is requested (0-15).

ERROR is returned if the value passed is not between 0-15. Channel 8 is selected by default.

Page 14: Simple Media Access Controller (SMAC)read.pudn.com/.../sourcecode/.../SMAC-manual.pdf · Document Number: SMACRM Rev. 1.2 04/2005 Simple Media Access Controller (SMAC) User’s Guide

SMAC Introduction

SMAC User’s Guide, Rev. 1.2

1-8 Freescale Semiconductor

1.5.6 MLMERXEnableRequestPlaces the MC1319x into receive mode on the channel selected byMLMESetChannelRequest ().

Prototype

UINT8 MLMERXEnableRequest(tRxPacket *psRxPacket, UINT32 u32Timeout);

Arguments

tRxPacket *:Location of the buffer to store the incoming data.

UINT32:32-bit timeout value.

Returns

{SUCCESS, ERROR}

Usage• Application creates a buffer to store incoming data. In the sample code, it is named

gau8RxDataBuffer.• Application declares a variable of type tRxPacket. In the sample code it is defined as

gsRxPacket.

• Load the address of the receive buffer into the * pu8Data field in the gsRxPacket variable.• Load the maximum packet length to receive into u8MaxDataLength field.• Call MLMERXEnableRequest with the tRxPacket variable and a 32-bit timeout value.• The SMAC will let the application know that data is received via the MCPSDataIndication

callback function.

Notes

ERROR return implies that the receiver did not go into receive mode.

u32Timeout value of zero causes the receiver to never timeout and stay in receive mode until a valid data packet is received or the MLMERXDisableRequest function is called. At those points the radio will return to idle mode.

To turn off the receiver before a valid packet is received, the MLMERXDisableRequest call can be used.

Page 15: Simple Media Access Controller (SMAC)read.pudn.com/.../sourcecode/.../SMAC-manual.pdf · Document Number: SMACRM Rev. 1.2 04/2005 Simple Media Access Controller (SMAC) User’s Guide

SMAC Introduction

SMAC User’s Guide, Rev. 1.2

Freescale Semiconductor 1-9

1.5.7 MLMERXDisableRequestReturns the MC1319x to idle mode from receive mode.

Prototype

UINT8 MLMERXDisableRequest(void);

Arguments

None

Returns

{SUCCESS}

Usage

Simply call MLMERXDisableRequest ().

Notes

This function can be used to turn off the receiver before a timeout occurs or when the receiver is in the always on mode.

1.5.8 MLMESetMC13192ClockRateThis function is called to set the desired clock out from MC1319x. The table of frequencies is shown in the notes section.

Prototype

UINT8 MLMESetMC13192ClockRate(UINT8 u8Freq);

Arguments

UINT8: An 8 bit value that represents MC1319x clock out frequency (CLKO). Expected values are 0-7.

Returns

{SUCCESS}

Notes

* FREQ OUTPUT_FREQ

* 0 16MHz (Recommended default)

* 1 8MHz

* 2 4MHz

* 3 2MHz

* 4 1MHz

* 5 62.5kHz

Page 16: Simple Media Access Controller (SMAC)read.pudn.com/.../sourcecode/.../SMAC-manual.pdf · Document Number: SMACRM Rev. 1.2 04/2005 Simple Media Access Controller (SMAC) User’s Guide

SMAC Introduction

SMAC User’s Guide, Rev. 1.2

1-10 Freescale Semiconductor

* 6 32.786kHz

* 7 16.393kHz

1.5.9 MLMEEnergyDetectThis call starts an energy detect (ED)/ Clear Channel Assessment (CCA) cycle and returns the energy value (-power/2) via the returned argument.

Prototype

UINT8 MLMEEnergyDetect(void);

Arguments

None

Returns

UINT8: An unsigned 8-bit value representing the energy on the current channel.

1.5.10 MLMEMC13192SoftResetThe MLMEMC13192SoftReset function is called to perform a soft reset to the MC1319x.

Prototype

UINT8 MLMEMC13192SoftReset(void);

Arguments

None

Returns

{SUCCESS}

Usage

Simply call the MLMEMC13192SoftReset () function directly.

Notes

When this function is called, a reset indication should be sent back to the application through the MLMEMC13192ResetIndication callback function. It is up to the application to handle this event.

Page 17: Simple Media Access Controller (SMAC)read.pudn.com/.../sourcecode/.../SMAC-manual.pdf · Document Number: SMACRM Rev. 1.2 04/2005 Simple Media Access Controller (SMAC) User’s Guide

SMAC Introduction

SMAC User’s Guide, Rev. 1.2

Freescale Semiconductor 1-11

1.5.11 MLMEMC13192XtalAdjustThis function is used to adjust the MC1319x reference clock by a trim value.

Prototype

UINT8 MLMEMC13192XtalAdjust(UINT8 u8ReqValue);

Arguments

UINT8: 8 bit value representing the trim value to the oscillator.

Returns

{SUCCESS}

Usage

Simply call the MLMEMC13192XtalAdjust () function directly.

1.5.12 MLMELinkQualityThis function returns an integer value that is the link quality from the last received packet of the form: dBm = (-Link Quality/2).

Prototype

UINT8 MLMELinkQuality (void);

Arguments

None

Returns

UINT8: 8 bit value representing the link quality value

Usage

Call MLMERXEnableRequest.

Wait for a MCPSDataIndication.

Call MLMELinkQuality.

Notes

The value of the link quality is valid and preserved until the next received packet.

Page 18: Simple Media Access Controller (SMAC)read.pudn.com/.../sourcecode/.../SMAC-manual.pdf · Document Number: SMACRM Rev. 1.2 04/2005 Simple Media Access Controller (SMAC) User’s Guide

SMAC Introduction

SMAC User’s Guide, Rev. 1.2

1-12 Freescale Semiconductor

1.5.13 MLMESetMC13192TmrPrescaleThis function changes the rate at which the MC1319x timers operate.

Prototype

UINT8 MLMESetMC13192TmrPrescale (UINT8 u8Freq);

Arguments

UINT8: 8 bit value representing the timer prescale. See the Notes for further details.

Returns

{SUCCESS}

Usage

Call MLMESetMC13192TmrPrescale ([0-7]).

Notes

These are the values supported by the argument of this primitive:

FREQ OUTPUT_FREQ

* 0 2MHz

* 1 1MHz

* 2 500kHz

* 3 250kHz (Recommended default)

* 4 125kHz

* 5 62.5kHz

* 6 31.25kHz

* 7 15.625kHz

1.5.14 MLMEMC13192FEGainAdjustThis is a compensator for the energy detection and AGC. The default value should be placed into the MC13192Init () (located in MC13192_hw_config.c file). But in the event users need to calibrate the readings due to a specific application like an external low noise amplifier, this is where users would set the offset.

Prototype

UINT8 MLMEMC13192FEGainAdjust(UINT8 u8GainValue);

Arguments

UINT8: 8 bit value for the gain adjust.

Page 19: Simple Media Access Controller (SMAC)read.pudn.com/.../sourcecode/.../SMAC-manual.pdf · Document Number: SMACRM Rev. 1.2 04/2005 Simple Media Access Controller (SMAC) User’s Guide

SMAC Introduction

SMAC User’s Guide, Rev. 1.2

Freescale Semiconductor 1-13

Returns

{SUCCESS}

Usage

MLMEMC13192FEGainAdjust (Default Value +/- 20)

Notes

It is recommended to adjust the FE gain within reasonable limits to prevent overflowing the link quality reading. The current default value is 0x8D. Figure 1-4 shows the Link Quality Indication versus FE gain.

Figure 1-4. Link Quality Indication versus FE Gain Adjust

1.5.15 MLMEDozeRequestDoze request lets the user put the MC1319x either in Normal Doze Mode (without CLKout but with automatic wakeup) or Acoma Mode (with CLKout, but without timeout). Review the MC13192/93 Reference Manual (MC13192RM) or MC13191 Reference Manual (MC13191RM) for details regarding Acoma and Normal Doze modes.

Prototype

UINT8 MLMEDozeRequest(UINT32 u32Timeout);

Arguments

UINT32 Is the automatic wake up time for this mode.

Returns

{SUCCESS}

Page 20: Simple Media Access Controller (SMAC)read.pudn.com/.../sourcecode/.../SMAC-manual.pdf · Document Number: SMACRM Rev. 1.2 04/2005 Simple Media Access Controller (SMAC) User’s Guide

SMAC Introduction

SMAC User’s Guide, Rev. 1.2

1-14 Freescale Semiconductor

Usage

To use Acoma mode: Users should call this function with “0” as parameter. Then, the SMAC will set the MC1319x in Acoma mode with enabled CLK Output. To exit from this state, users should call the MLMEWakeRequest function.

To use Normal Doze mode: Users should call this function with the desired timeout. Then the SMAC will put the MC1319x in doze mode. This will give the user only 128 clock pulses more before disconnecting CLKO, so users might execute a low power instruction (such wait). Once the timeout is reached, the MC1319x will wake up and perform an IRQ Interrupt (attended by the SMAC).

Notes

The maximum clock out frequency during doze mode or Acoma mode is equal to or less than 1MHz. The SMAC does no error checking for this when entering doze mode. The application needs to handle this requirement.

1.5.16 MLMEMC13192PAOutputAdjustThis function adjusts the output power of the transmitter

Prototype

UINT8 MLMEMC13192PAOutputAdjust(UINT8 u8PaValue);

Arguments

UINT8: 8 bit value for the output power desired. Values 0-15 are required.

Returns

{SUCCESS, OVERFLOW}

Usage

This function can be called with an argument between 0 and 15 or using the MIN_POWER, MAX_POWER and NOMINAL_POWER macros. Table 1-1 shows these values.

Table 1-1. U8PaValue

U8PaValue value

Typical Differential Power at Output Contact (dBm)

U8PaValue value

Typical Differential Power at Output Contact (dBm)

0b0000 -16.6 0b1000 -1.0

0b0001 -16.0 0b1001 -0.5

0b0010 -15.3 0b1010 0.0

0b0011 -14.8 0b1011 0.4

0b0100 -8.8 0b1100 2.1

0b0101 -8.1 0b1101 2.8

Page 21: Simple Media Access Controller (SMAC)read.pudn.com/.../sourcecode/.../SMAC-manual.pdf · Document Number: SMACRM Rev. 1.2 04/2005 Simple Media Access Controller (SMAC) User’s Guide

SMAC Introduction

SMAC User’s Guide, Rev. 1.2

Freescale Semiconductor 1-15

Notes

OVERFLOW is returned when this function is called with a value >15.

1.5.17 MLMEGetRficVersionThis function is used to read the version number of the MC1319x.

Prototype

UINT8 MLMEGetRficVersion(void);

Arguments

None

Returns

UINT8: 8 bit value representing the version of the MC1319x

Usage

Simply call the MLMEGetRficVersion() function.

1.5.18 MLMETestModeBy employing this function, users can execute a test of the MC1319x. Some basic test modes are necessary to assist SMAC users evaluate their hardware. A SMAC API call was added that places the MC1319x into basic tests modes.

Prototype

void MLMETestMode (tTxPacket *psPacket, UINT8 u8mode);

Arguments

tTxPacket: A packet to transmit.

UINT8: The test mode to start.

Returns

void

Usage

Call the MLMETestMode() function with the packet to be transmitted and the mode to be executed. See the notes for a list of modes implemented.

Notes

0b0110 -7.5 0b1110 3.5

0b0111 -6.9 0b1111 3.6

Table 1-1. U8PaValue

Page 22: Simple Media Access Controller (SMAC)read.pudn.com/.../sourcecode/.../SMAC-manual.pdf · Document Number: SMACRM Rev. 1.2 04/2005 Simple Media Access Controller (SMAC) User’s Guide

SMAC Introduction

SMAC User’s Guide, Rev. 1.2

1-16 Freescale Semiconductor

This is a list of the modes implemented, defined as Macros:PULSE_TX_PRBS9: Used to continuously transmit a PRBS9 pattern.FORCE_IDLE: Forces the MC1319x to back to the original IDLE mode.CONTINUOUS_RX: Sets the MC1319x into continuous RX mode.CONTINUOUS_TX_MOD: This test will set the device to continuously transmit a 10101010 pattern.CONTINUOUS_TX_NOMOD:This will set the device to continuously transmit an unmodulated CW.

1.5.19 MLMEMC13192ResetIndication This callback function (a function that is located within the user’s application code and is needed by the SMAC) needs to be placed in the application. This allows the SMAC to call this function when a SoftReset has occurred. It is used as follows:

Prototype

void MLMEMC13192ResetIndication(void);

Arguments

(none)

Returns

void

Usage

This function should deal with the soft reset condition on the MC1319x triggered by the MLMEMC13192SoftReset() function.

1.6 Low Noise Amplifier (LNA) and Antenna Switch SupportThe SMAC provides support to use an LNA or antenna switch for external antennas.

The LNA uses a pin to turn the LNA hardware on and off. To reduce power consumption, the LNA is activated when the transceiver is configured for reception and deactivated as soon as a packet is received.

The antenna switch uses either 1 or 2 pins. Some switches use two pins to set TX or RX. Most use 1 state for TX and another for RX. Those are automatically managed by the SMAC.

If users are planning to implement the LNA or the antenna switch, the following macros should be defined within the application code:LNA: To enable the Low Noise Amplifier support.ANTENNA_SWITCH: To enable the Antenna Switch support.

It is important to note that the external pins to interface with such hardware are defined in the “Port Defs”, within the SMAC project. If planning to create a different hardware, another file should be created that attaches the pin with the functionality of SMAC.

Page 23: Simple Media Access Controller (SMAC)read.pudn.com/.../sourcecode/.../SMAC-manual.pdf · Document Number: SMACRM Rev. 1.2 04/2005 Simple Media Access Controller (SMAC) User’s Guide

SMAC User’s Guide, Rev. 1.2

Freescale Semiconductor 2-1

Chapter 2 SMAC Data TypesThis chapter details the SMAC custom data types.

2.1 Fundamental data typesThe following list shows the fundamental data types used and the naming convention used in SMAC:UINT8: unsigned 8 bit definition UINT16: unsigned 16 bit definitionUINT32: unsigned 32 bit definitionINT8: signed 8 bit definition INT16: signed 16 bit definitionINT32: signed 32 bit definition

Usage

These data types are used in the SMAC project as well as in the Applications projects and they are defined in the file pub_def.h.

2.2 tTxPacketThis structure defines the variable to be transmitted by the SMAC. It is located in pub_def.h and its definition is the following:typedef struct { UINT8 u8DataLength; UINT8 *pu8Data;} tTxPacket;

Members

u8DataLength Is the number of bytes to transmit.

* pu8Data Is a pointer to the data buffer to transmit.

Usage

This data type is used by an application in the following manner:1. The application instantiates a variable: tTxPacket gsTxPacket;2. The application creates a data buffer of data to send: UINT8 gau8TxDataBuffer[20];3. The application loads the number of bytes to send into u8DataLength in the tTxPacket structure:

gsTxPacket.u8DataLength = 0;

Page 24: Simple Media Access Controller (SMAC)read.pudn.com/.../sourcecode/.../SMAC-manual.pdf · Document Number: SMACRM Rev. 1.2 04/2005 Simple Media Access Controller (SMAC) User’s Guide

SMAC Data Types

SMAC User’s Guide, Rev. 1.2

2-2 Freescale Semiconductor

4. The application loads the address of the data buffer to send into data field of the gsTxPacket structure: gsTxPacket.pu8Data = &gau8TxDataBuffer[0];

2.3 tRxPacketThis is a structure that defines the variable to be received by the SMAC. It is also located in pub_def.h and its definition is:typedef struct { UINT8 u8MaxDataLength; UINT8 u8DataLength; UINT8 *pu8Data; UINT8 u8Status;} tRxPacket;

Members

u8MaxDataLength: Is a field that specifies the maximum packet size to accept. If the packet received is greater than u8MaxDataLength then the packet is dropped and the application is not notified.

u8DataLength: Is a field containing the length in bytes of the received packet.

*pu8Data: This pointer specifies to the SMAC where the application would like to have the received data copied into.

u8Status: This field has two possibilities: {SUCCESS, TIMEOUT}. This field allows the application to determine if the data indication is due to a received packet or a timeout. The application must in the MCPSDataIndication check this field to determine if the indication is due to a timeout or good data.

Page 25: Simple Media Access Controller (SMAC)read.pudn.com/.../sourcecode/.../SMAC-manual.pdf · Document Number: SMACRM Rev. 1.2 04/2005 Simple Media Access Controller (SMAC) User’s Guide

SMAC User’s Guide, Rev. 1.2

Freescale Semiconductor 3-1

Chapter 3 Using the Embedded BootloaderThis chapter explains how to download an application to a Board using the Embedded Bootloader Test Tool utility.

3.1 Requirements• The Freescale Test Tool installed in the PC• A serial port• The boards should never have been previously programmed through a BDM Multilink

NOTEProgramming of the users ZigBee boards with a BDM Multilink erases the Embedded Bootloader that comes already flashed in the board.

If users have the DIG-528 or DIG-536 board, those came pre-programmed with an application demo and the “Embedded Bootloader”, which is software that allows users to download other applications to their new board via RS232 (so they don’t have to buy a programmer).

However, if users want to test the other demos or the applications that they create, they will have to download them to their board.

1. Generate the S19 file. The S19 file is the binary file that is executable in the microcontroller and is the only file users need to download to their board. In order to generate it, users need to open the desired project, choose the correct target (should be “_loader” compatible) and compile it. This way an S19 file will be created.

2. Locate the demo S19 file. According to the SMAC folder structure, the S19 files are in the “bin” directory within the specific application folder. For example:

\SMAC4.1\S08\apps\Accel_V2.0\3.1 Project\bin\SMAC4.1\S08\apps\Wireless Uart\3.1\bin\SMAC4.1\S08\apps\SMAC Application Template\3.1\bin\SMAC4.1\S08\apps\Range demo Plus\Range Demo Plus RX\3.1\bin\SMAC4.1\S08\apps\Range demo Plus\Range Demo Plus TX\3.1\bin\SMAC4.1\S08\apps\Packet Error Rate with ACKs (Min TX Power)\3.1\bin\SMAC4.1\S08\apps\Lighting Demo\Lighting_demo_controller\3.1\bin\SMAC4.1\S08\apps\Lighting Demo\Lighting_demo_device\3.1\bin

There, users will find a lot of .S19 and .ABS files which are the recognizable formats to program the Microcontroller. Now users need to choose their application. Use the S19 file for the target selected. For example, users want to download the Range Demo TX Application for a SARD board. Users need to choose the file “range_demo_plus_rx_13192SARD_SE.S19”

• range_demo_plus_rx is the name of the application.• 13192SARD is the name of the board in which users are downloading.

Page 26: Simple Media Access Controller (SMAC)read.pudn.com/.../sourcecode/.../SMAC-manual.pdf · Document Number: SMACRM Rev. 1.2 04/2005 Simple Media Access Controller (SMAC) User’s Guide

Using the Embedded Bootloader

SMAC User’s Guide, Rev. 1.2

3-2 Freescale Semiconductor

• SE is in the file name because users opened the “Special Edition” license project. See Chapter 1, SMAC Introduction.

3. Copy the S19 file. Once users have their S19 File, the next step is to copy it to the Test Tool directory. It is normally installed in the directory C:\Program Files\Freescale\Test Tool\. Then the user will need to copy the S19 file to C:\Program Files\Freescale\Test Tool\s19.

4. Open the Test Tool utility.5. Configure the communication Settings. Under the assumption that users have not done this, they

should execute the command “Tools/Communication Settings”. A list of communication configurations will come up and they have to make sure they have a “COM1 @ 19200” element (or the COM port they will use). If not, click Add Internal and configure it.

6. Open the View/“ZigBee Bootloader”, then select the Communication setup needed (i.e. “ZigBee: COM1 [19200]”).

7. Turn their board on and enter into Bootloader mode (all LEDs should be on). In order to do that, reset the board while keeping the four pushbuttons pressed.

In the window main area, read the name of the application file (s19) just copied in Step2 and click on it. Make sure that all the “Upload settings” are selected and then click on “Upload”.

Users will see the following messages in the status bar.“Freeloader started successfully”“Flash erased”“Firmware downloaded – automatic reset requested.”

They have now downloaded their code to the board.

NOTEIf users do not enter the Embedded Bootloader mode prior to “Uploading” their application, they will get an error message.

If users received the popup message “Timeout waiting for Download Firmware to complete!” Perform the procedure shown in Figure 3-1. This procedure shows the procedure to follow if the user is unable to download an application using the Embedded Bootloader.

Page 27: Simple Media Access Controller (SMAC)read.pudn.com/.../sourcecode/.../SMAC-manual.pdf · Document Number: SMACRM Rev. 1.2 04/2005 Simple Media Access Controller (SMAC) User’s Guide

Using the Embedded Bootloader

SMAC User’s Guide, Rev. 1.2

Freescale Semiconductor 3-3

Figure 3-1. Unable to Download an Application Procedure

When following this procedure, users can choose one of the branches that appear here.

Error message

Review comm settings

Are all LEDs on ?

1

*Enter in Bootloader mode by resetting the board while pressing all four pushbuttons

Press S101 for 5 * sec, then release it

Press S102 for 5 * sec, then release it

LEDS = 0001 ?

LEDS = 1101 ?

Unable to enter in bootloader

mode

You are not in Bootloader mode. Enter in it by resetting the board while pressing all four pushbuttons

1

Review comm settings

END

Yes

No

Yes

No

No

Yes

*Enter in Bootloader mode. SAFE MODE: All flash is erased (except production data and MAC address) 1. Power off the board 2. Disconnect RS232 UART cable (if the RS232 UART interface is used) 3. Short UART TX and RX (pin 2-3 in MCU) 4. Power up again. All LEDs are off. 5. Wait until LED1 goes on (< 1 second) 6. Power off the board 7. Remove short from UART TX and RX and connect UART cable again (if the RS232 UART interface is used) 8. Power up again 9. Embedded Bootloader is ready to receive new firmware (all LEDs on) 10. Start the PC-Tool. See Chapter 3, for more information.

Page 28: Simple Media Access Controller (SMAC)read.pudn.com/.../sourcecode/.../SMAC-manual.pdf · Document Number: SMACRM Rev. 1.2 04/2005 Simple Media Access Controller (SMAC) User’s Guide

Using the Embedded Bootloader

SMAC User’s Guide, Rev. 1.2

3-4 Freescale Semiconductor

Page 29: Simple Media Access Controller (SMAC)read.pudn.com/.../sourcecode/.../SMAC-manual.pdf · Document Number: SMACRM Rev. 1.2 04/2005 Simple Media Access Controller (SMAC) User’s Guide

SMAC User’s Guide, Rev. 1.2

Freescale Semiconductor A-1

Appendix A Migrating from SMAC 4.0 to SMAC 4.1This Appendix describes how to migrate a project from SMAC Version 4.0 to SMAC Version 4.1. There are two main issues when migrating a SMAC 4.0 compatible application to SMAC 4.1.

1. The Application Programming Interface (API) has changed, so references to SMAC functions should be updated.

2. The folder structure of the SMAC has changed, so access paths should be updated in the targets of the application.

User will need to change the references to certain functions, data types, and global variables as shown in the following table.

Table A-1. Functions to Change For Migration

Change from Change to

MCPS_data_request MCPSDataRequest

MLME_hibernate_request MLMEHibernateRequest

MLME_wake_request MLMEWakeRequest

MLME_set_channel_request MLMESetChannelRequest

MLME_RX_enable_request MLMERXEnableRequest

MLME_RX_disable_request MLMERXDisableRequest

MLME_set_MC13192_clock_rate MLMESetMC13192ClockRate

MLME_energy_detect MLMEEnergyDetect

MLME_MC13192_soft_reset MLMEMC13192SoftReset

MLME_MC13192_xtal_adjust MLMEMC13192XtalAdjust

MLME_link_quality MLMELinkQuality

MLME_set_MC13192_tmr_prescale MLMESetMC13192TmrPrescale

MLME_MC13192_FE_gain_adjust MLMEMC13192FEGainAdjust

MLME_doze_request MLMEDozeRequest

MLME_MC13192_PA_output_adjust MLMEMC13192PAOutputAdjust

MLME_get_rfic_version MLMEGetRficVersion

MCPS_data_indication MCPSDataIndication

MLME_MC13192_reset_indication MLMEMC13192ResetIndication

mcu_init MCUInit

Page 30: Simple Media Access Controller (SMAC)read.pudn.com/.../sourcecode/.../SMAC-manual.pdf · Document Number: SMACRM Rev. 1.2 04/2005 Simple Media Access Controller (SMAC) User’s Guide

Migrating from SMAC 4.0 to SMAC 4.1

SMAC User’s Guide, Rev. 1.2

A-2 Freescale Semiconductor

In the SMAC 4.0 there are some functions requiring or returning interrupts, but they have been changed to UINT8 in SMAC4.1. Refer to the simple_mac.h file for more information.

Regarding the structures, users should be aware that their members’ names have changed. For example a tx_packet.dataLength is no longer valid and should be changed to tx_packet.u8DataLength.

Because the folder structure has changed, some access paths are no longer valid and others are needed in order to run the applications.

Each application project has several targets. A target is a set of configurations to create a specific application with a certain profile. One of the configurations of the targets is the “Access Paths”, which are a way that users tell the compiler where it will search for the files.

Figure A-1 shows the window in which the Access Paths are located.

MC13192_init MC13192Init

use_external_clock UseExternalClock

irq_isr IRQIsr

Table A-2. Data Types to Change For Migration

Change from Change to

__uint8__ UINT8

__uint32__ UINT32

int UINT16

typedef struct { __uint8__ maxDataLength; __uint8__ dataLength; __uint8__ *data; __uint8__ status;} rx_packet_t;

typedef struct { UINT8 u8MaxDataLength; UINT8 u8DataLength; UINT8 *pu8Data; UINT8 u8Status;} tRxPacket;

typedef struct{ __uint8__ dataLength; __uint8__ *data;} tx_packet_t;

typedef struct { UINT8 u8DataLength; UINT8 *pu8Data;} tTxPacket;

Table A-3. Global Variables to Change For Migration

Change from Change to

rtx_mode gu8RTxMode

Table A-1. Functions to Change For Migration (continued)

Page 31: Simple Media Access Controller (SMAC)read.pudn.com/.../sourcecode/.../SMAC-manual.pdf · Document Number: SMACRM Rev. 1.2 04/2005 Simple Media Access Controller (SMAC) User’s Guide

Migrating from SMAC 4.0 to SMAC 4.1

SMAC User’s Guide, Rev. 1.2

Freescale Semiconductor A-3

Figure A-1. Target Settings Dialog Box

In order to open the Target Settings dialog box, users should first select the target required. Then they should click on “1” and the dialog box appears. By selecting the “Access Paths” on the left, the right pane (“2”) shows the locations where the project files are searched.

Figure 6 shows the access paths for the Wireless UART project, which are almost identical as most of the other applications. Users must ensure that all needed files in the project are accessible. It is recommended (but not mandatory) that when users have a proprietary application, the application is located as if it were just another demo application so that the Access Paths are nearly identical.

Page 32: Simple Media Access Controller (SMAC)read.pudn.com/.../sourcecode/.../SMAC-manual.pdf · Document Number: SMACRM Rev. 1.2 04/2005 Simple Media Access Controller (SMAC) User’s Guide

Migrating from SMAC 4.0 to SMAC 4.1

SMAC User’s Guide, Rev. 1.2

A-4 Freescale Semiconductor

Page 33: Simple Media Access Controller (SMAC)read.pudn.com/.../sourcecode/.../SMAC-manual.pdf · Document Number: SMACRM Rev. 1.2 04/2005 Simple Media Access Controller (SMAC) User’s Guide

SMAC User’s Guide, Rev. 1.2

Freescale Semiconductor B-1

Appendix B SMAC C-coding StandardThis appendix provides a quick reference for the C Coding standard in which the SMAC 4.1 was created.

Table B-1. C Coding Standard

• VariablesUse typedef for projects and prefixUse uppercase only to separate wordsUse descriptive names/* Examples of Variable declarations */UINT8 u8Counter;UINT16 u16Temporal;UINT32 u32LongCounter;INT8 gi8Flags;UINT8 aTable[];

The available prefixes are:_ g: global_ i8: signed integer 8 bits_ i16: signed integer 16 bits_ i32: signed integer 32 bits_ u8: unsigned integer 8 bits_ u16: unsigned integer 16 bits_ u32: unsigned integer 32 bits_ b: Boolean_ s: structure_ p: pointer_ a: array

• MacrosUse Uppercase and underscoresCast when necessary and place prefix/* Examples of Macro declarations */#define START_CONVERSION(Channel) ADSCR = 0x40 | (Channel)#define i16_BASE_OF_FIGURE ((UINT16) 5000)

• FunctionsUse uppercase to separate wordsFirst word for moduleBracket in same lineInclude prototype with all parametersUse static when function is used within the module onlyExternally accessible functions can be declared in a separate header file or using the extern keyword in anothersource file/* Examples of function prototypes */UINT8 SPITransferByte(UINT8 u8Data);static UINT8 SPIConvertHex(UINT8 u8HexData);/* Example of function declarations */void SPISendByte(UINT8 u8Data){/* Variables in here *//* Body of function in here */return;}

• For/* Example of for statement */for (u8Counter = 0; u8Counter < COUNT_MAX ; u8Counter++) {/* Statements in here */}

• Infinite loop/* Examples of infinite loop statement */for (;;); /* Empty Body */for (;;) {/* Statements in here */}

Page 34: Simple Media Access Controller (SMAC)read.pudn.com/.../sourcecode/.../SMAC-manual.pdf · Document Number: SMACRM Rev. 1.2 04/2005 Simple Media Access Controller (SMAC) User’s Guide

SMAC C-coding Standard

SMAC User’s Guide, Rev. 1.2

B-2 Freescale Semiconductor

• While/* Examples of while statement */while (!u8Status); /* Empty Body */while (u8Status != FALSE) {/* Statements in here */}

• If/* Examples of if statement */if (!u8Temporal) {/* Statements in here */}if (!u8Data) {/* Statements in here */}else {/* Statements in here */}

• Switch/* Example of switch statement */switch (u8Character) {case ‘A’:/* Statements in here *//* falls through */case ‘B’:/* Statements in here */break;default:/* Statements in here */break;}

• Do-While/* Example of do-while statement */do {/* Statements in here */} while (!PTA_PTA0);

• Structures/* Example of structure definition using typedef*/typedef struct {UINT8 u8Character;UINT16 u16Counter;} tMixture;/* Example of declaration and initialization */tMixture sMyMix[] = {{'a', 0x3c4b},{'b', 0xffff}};

• Comments/* Examples of comments */PORTA = 0xFF; /* Set PortA to drive all outputs high *//* Flag serial communication error */u8GlobalErrors |= COMMUNICATION ERROR;/* Example of Block of comments */ADICLK = 0x40; /** ADC Clock Rate = BusClock/4* BusClock/4 = 3.2Mhz/4 =0.8Mhz* The ADC clock frequency should be set between* fADIC(MIN) = 0.5Mhz and fADIC(MAX) = 1.048Mhz*/

• Indentation and spaces rulesAll function declarations shall begin in column 1All macro definitions shall be begin in column 1Avoid lines longer than 80 characters.All indentation shall be done using four spacesAvoid using tabsDon’t place spaces for unary operators, beginning or ending functions or typecastingUse spaces for assignment operators, conditional operators, relational operators, logical operators, arithmeticoperators, and bitwise operators; commas and semicolons.

Table B-1. C Coding Standard (continued)

Page 35: Simple Media Access Controller (SMAC)read.pudn.com/.../sourcecode/.../SMAC-manual.pdf · Document Number: SMACRM Rev. 1.2 04/2005 Simple Media Access Controller (SMAC) User’s Guide

SMAC User’s Guide, Rev. 1.2

Freescale Semiconductor C-1

Appendix C Restoring the Embedded BootloaderThis appendix describes how to restore the Embedded Bootloader to the DIG-528, DIG-536 and Axiom GB60 Evaluation Boards.

To restore the Embedded Bootloader users need the following:1. A copy of SMAC project (downloadable from: www.freescale.com/ZigBee)2. CodeWarrior for HCS08 3.1 installed3. A BDM pod installed4. The Test Tool Utility

Proceeding:1. Start the “True-Time Simulator & Real-Time Debugger” (located in

C:\Program Files\Metrowerks\CW08 V3.1\prog\hiwave.exe ). (Figure C-1)a) Now users must select the target:

Component/Set Target: Choose HCS08 as processor and the proper Target interface (P&E Target Interface for P&E BDM Multilink). Figure C-2

2. Choose the correct device:a) PEDebug/Device/68HCS08/GT Family/GT60 (or the proper MCU). (Figure C-3)b) Now users must load the Embedded_Bootloader.S19 file from:

SMAC4.1\S08\tools\Embedded_Bootloader\DIG-528-2_&_DIG-536-2\

c) (Make sure users select in “Files of type” the value “Freescale S-Record(*.s?*)”). Figure C-4d) Once loaded to the debugger, go to PEDebug/Mode/In-Circuit Debug\Programming.

(Figure C-4)e) Click OK

The Embedded Bootloader will begin to download to the board. Once loaded, users can employ the Test Tool Utility to change the MAC Address and other information as well as to download the Embedded Bootloader compatible applications.

Page 36: Simple Media Access Controller (SMAC)read.pudn.com/.../sourcecode/.../SMAC-manual.pdf · Document Number: SMACRM Rev. 1.2 04/2005 Simple Media Access Controller (SMAC) User’s Guide

Restoring the Embedded Bootloader

SMAC User’s Guide, Rev. 1.2

C-2 Freescale Semiconductor

Figure C-1. True-Time Simulator & Real-Time Debugger

Figure C-2. Choosing a Target

Page 37: Simple Media Access Controller (SMAC)read.pudn.com/.../sourcecode/.../SMAC-manual.pdf · Document Number: SMACRM Rev. 1.2 04/2005 Simple Media Access Controller (SMAC) User’s Guide

Restoring the Embedded Bootloader

SMAC User’s Guide, Rev. 1.2

Freescale Semiconductor C-3

Figure C-3. Choosing a Device

Figure C-4. PEDebug/Mode/In-Circuit Debug\Programming

Page 38: Simple Media Access Controller (SMAC)read.pudn.com/.../sourcecode/.../SMAC-manual.pdf · Document Number: SMACRM Rev. 1.2 04/2005 Simple Media Access Controller (SMAC) User’s Guide

Restoring the Embedded Bootloader

SMAC User’s Guide, Rev. 1.2

C-4 Freescale Semiconductor