CEL ZFSM-201-EVB-1 Manual

Free Star Pro Series
ZFSM-201-EVB-1
Evaluation Board
MAC Programmers’ Guide
ZFSM-201-1 FreeStar Pro Module
Document # 0006-00-08-05-000
(Rev B)

FreeStar Pro MAC Programmers’ Guide
Rev B 0006-00-08-05-000 Page 2 of 33
TableofContents
1OVERVIEW.........................................................................................................4
1.1DESCRIPTION ............................................................................................4
1.2REFERENCED DOCUMENTS ....................................................................4
2CODE DEVELOPMENT IN IAR WORKBENCH®..............................................5
2.1TOOLS.........................................................................................................5
2.1.1IAR Embedded Workbench® for ARM.......................................................................... 5
2.1.2J-Link............................................................................................................................... 6
2.2PROJECT OVERVIEW................................................................................6
2.2.1File Location on the CD ................................................................................................. 6
2.3DEBUG/RELEASE WORKSPACE MODE ..................................................7
2.4APPLICATION FILES..................................................................................7
2.4.1Source Files.................................................................................................................... 7
2.4.2Utility files ....................................................................................................................... 8
2.5PLMAND MAC SOURCE FILES.................................................................9
2.6J-LINK SPEED ............................................................................................9
2.6.1Change the J-Link speed by following steps:........................................................... 10
2.7OPTIMIZATIONS.......................................................................................10
2.8MAIN IAR FEATURES...............................................................................11
2.8.1Building a Project..........................................................................................................11
2.8.2Downloading into Flash:...............................................................................................11
3MAC DEVELOPMENT WITH SAMPLE APPLICATION...................................12
3.1CODE DEVELOPMENT ............................................................................12
3.2TASK SCHEDULER........................................................................................13
3.2.1Task Priority.................................................................................................................. 13
3.2.2Adding a Task............................................................................................................... 13
3.2.3Task Events................................................................................................................... 14
3.2.1Sending an Event ......................................................................................................... 14
3.2.2Clearing an Event......................................................................................................... 14
3.3TIMER INTERFACE.........................................................................................14
3.3.1Allocating a Timer ........................................................................................................ 14
3.3.2Starting a Single Shot Timer....................................................................................... 14
3.3.3Starting an Interval Timer............................................................................................ 15
3.4INTERFACING WITH THE MAC........................................................................15
3.4.1SAP Handlers................................................................................................................ 15
3.5SENDING AND RECEIVING RF MESSAGES.......................................................15
3.5.1Setting Up Network ...................................................................................................... 15
3.5.2Changing RF Power ..................................................................................................... 15
3.5.3All other Network Parameters..................................................................................... 16
3.5.4Sending a RF Message................................................................................................ 18

FreeStar Pro MAC Programmers’ Guide
Rev B 0006-00-08-05-000 Page 3 of 33
3.5.5Receiving a RF Message ............................................................................................. 19
3.6STATE DIAGRAMS ...................................................................................20
3.6.1Main State Diagram...................................................................................................... 20
3.6.2AppInit State Diagram.................................................................................................. 21
3.6.3Transmit/Receive RF Message State Diagram.......................................................... 22
3.6.4PERT Transmit Message State Diagram.................................................................... 23
3.6.5Hibernate using 2kHz Oscillator State Diagram........................................................ 24
3.6.6Hibernate using 32kHz Oscillator State Diagram...................................................... 25
3.6.7Doze using 24MHz Reference Oscillator State Diagram .......................................... 26
3.6.8Enable Buck Regulator State ...................................................................................... 27
3.6.9Save to NVM State Diagram ........................................................................................ 28
3.6.10NVM Read State Diagram ............................................................................................ 29
3.6.11UART Receive State Diagram...................................................................................... 30
3.6.12Reading ADC’s State Diagram .................................................................................... 31
3.7RECEIVINGAUART MESSAGE...............................................................32
3.8TRANSMITTINGAUART MESSAGE .......................................................32
3.9TIMERS .....................................................................................................32
3.10EVENTS.....................................................................................................32
3.11READING ADC’S.......................................................................................32
3.12USER INPUTS (SWITCHES).....................................................................33
4REVISION HISTORY ........................................................................................33

FreeStar Pro MAC Programmers’ Guide
Rev B 0006-00-08-05-000 Page 4 of 33
1 Overview
1.1 DESCRIPTION
The ZFSM201-EVB-1 FreeStar Pro Evaluation Board serves as an interface, evaluation and
development tool enabling the user to demonstrate, and evaluate the capabilities of the CEL
ZFSM-201-1, FreeStar Pro Module.
At the heart of the CEL ZFSM-201-1 is the Freescale MC13224V Platform-in-Package (PiP)
transceiver, a 32-bit ARM-based ZigBee radio module and a third-generation 2.4GHz IEEE®
802.15.4 platform.
The 32-bit ARM7 processor and extensive on-chip memory allows designers to eliminate the
peripheral host processors often required by 8- and/or 16-bit transceiver solutions. The high
level of integration also helps to reduce component count, lowering power consumption and
reducing overall system cost.
The evaluation kit provides the end user the ability to quickly become familiar with both the
ZFSM-201-1 FreeStar Pro module’s hardware and software. The evaluation boards come
preloaded with firmware demonstrating a wireless link and communicating with the supplied
FreeStar Pro Test Tool Graphical User Interface (GUI).
The full application source code of the pre-programmed firmware is based on Freescale’s
MAC codebase for ARM7® and is supplied in an IAR Embedded Workbench for ARM
project. The source code exercises key features of the MC13224V and provides a good
reference or starting point for creating custom applications on the SMAC codebase.
RF Evaluation
Range Test Application
Packet Error Rate Test (PERT)Application
Transmitting and receiving on the UART
Using low power modes
Reading and writing to Non-Volatile Memory (NVM)
Reading Analog to Digital Converters
Setting up and running background timers
Using GPIOs
1.2 REFERENCED DOCUMENTS
Error! Reference source not found. contains the documents that have been referenced by
this document (or recommended as additional information). Please consult the appropriate
website to check for the latest revisions and editions.
Table 1 – Related and Referenced Documents
Document Title Document Name / Number
Freescale Semiconductor Documents
(www.freescale.com)
BeeKit™
Wireless Connectivity Toolkit Quick Start Guide BKWCTKQSG
BeeKit™
Wireless Connectivity Toolkit User’s Guide BKWCTKUG
BeeKit™
Wireless Connectivity Toolkit Software Release Notes BKWCTKRN

FreeStar Pro MAC Programmers’ Guide
Rev B 0006-00-08-05-000 Page 5 of 33
Document Title Document Name / Number
MC13224V
Datasheet MC1322x
MC1322x
Reference Manual MC1322xRM
MC1322x
Software Driver Reference Manual 22XDRVRRM
MC1322x
Simple Media Access Controller (SMAC) Reference Manual 22xSMACRM
802.15.4 Media Access Controller (MAC) MyWirelessApp 802154MWAUG
802.15.4 Media Access Controller (MAC MyStarNetworkApp 802154MSNAUG
802.15.4 MAC PHY Software Reference Manual 802154MPSRM
Simple Media Access Controller (SMAC) User’s Guide SMACRM
Freescale
Test Tool
User’s Guide TTUG
Note
: The Freescale documents listed above will be loaded to the user’s PC when installing the
BeeKit™
Toolkit
found on the CEL Freestar Pro CD.
CEL Documents
(www.cel.com)
ZFSM-201-1
Datasheet 0006-00-07-00-000
ZFSM-201-KIT-1
Development Kit User Guide 0006-00-08-00-000
ZFSM-201-EVB-1
Evaluation Board Host Serial & RF Protocol Guide
0006-00-08-01-000
ZFSM-201-EVB-1
Evaluation Board SMAC Programmers Guide 0006-00-08-02-000
ZFSM-201-EVB-1
Evaluation Board BeeKit™ Porting Guide
0006-00-08-03-000
ZFSM-201-EVB-1
Evaluation Board MAC Programmers Guide 0006-00-08-05-000
ZFSM-201-KIT-1
Wireless UART Application User Guide
0006-00-08-06-000
ZFSM-201-KIT-1
,
ZFSM-201-EVB-1
Erratum 0006-00-08-04-000
Note
: The CEL documents listed above are included on the CEL CD.
2 Code Development in IAR Workbench®
Figure 1 – Screen, IAR Website, Workbench®
2.1 TOOLS
2.1.1 IAR Embedded Workbench® for ARM
Several options exist to purchase or evaluate this program.
See
www.iar.com for details.
The included MAC project on the CD was developed in IAR Embedded Workbench®
for ARM version 5.20.

FreeStar Pro MAC Programmers’ Guide
Rev B 0006-00-08-05-000 Page 6 of 33
2.1.2 J-Link
Figure 2 – Photo, J-Link Debugging Probe
The IAR J-Link is necessary for in-circuit debugging.
See
www.iar.com for more details and where to purchase.
Download and install the latest driver from http://www.segger.com/download_jlink.html
2.2 PROJECT OVERVIEW
2.2.1 File Location on the CD
A complete IAR project, developed based on the BeeKit™ MAC codebase is included on
the CEL CD in the directory \ZFSM-201\Application Source Files\CEL_MAC_111_v1.3
\CEL_MAC_111\. It is entitled ‘CEL_MAC_111.eww’. The project was based on the
‘MyWirelessApp Demo Framework’ template in BeeKit™ (see Figure 3).
Figure 3 – Screen, BeeKit – New Project

FreeStar Pro MAC Programmers’ Guide
Rev B 0006-00-08-05-000 Page 7 of 33
2.3 DEBUG/RELEASE WORKSPACE MODE
During development it is strongly recommended that the ‘Workspace’ be kept in ‘Debug’
mode as shown in Figure 4.
Figure 4 – Screen, IAR Workbench – Debug mode
2.4 APPLICATION FILES
Figure 5 – Screen, IAR Workbench – Application Source
NOTE:
The screenshots used in this user guide may be based on a prior release of the corresponding Freescale
codebase, for version / project information with regards to the example included on the CEL CD, please refer to
Section
Error! Reference source not found.
. For the latest Freescale codebase, please download the Freescale
BeeKit™ from the Freescale website.
2.4.1 Source Files
As shown in Figure 5, seven application source files are included in the Sample Project.
Except for generic_app.c, each file also has a corresponding header (.h) file.
application_adc.c - Contains the source code necessary to setup and read
ADC’s.
application_nvm.c - Contains the source code necessary to write to NVM.

FreeStar Pro MAC Programmers’ Guide
Rev B 0006-00-08-05-000 Page 8 of 33
application_mac.c - This code contains the base applications for the CEL/MAC
release:
oRange test
oPacket error rate test
oContinuous receive
oPsuedo random binary sequency tx
MApp_app.c - Main C file exported out of BeeKit.
low_power.c - Contains the code necessary to place the device into low power
modes.
main_app.c - Contains the code the run the main state machine, various support
functions.
uart_parse.c - Handles incoming and outgoing UART messages.
2.4.2 Utility files
Figure 6 – Utility Source Files
The UartUtil module included with the project when made by BeeKit™ is located in the
‘Applications folder as shown in Figure 6.

FreeStar Pro MAC Programmers’ Guide
Rev B 0006-00-08-05-000 Page 9 of 33
2.5 PLM AND MAC SOURCE FILES
Additional Source files are included in the project when made by BeeKit™ and stored in the
PLM and MAC directories. They are shown in Figure 7 below.
Figure 7 – Screen, IAR Workbench – PLM and MAC Source Files
2.6 J-LINK SPEED
Figure 8 – Selecting Project Options

FreeStar Pro MAC Programmers’ Guide
Rev B 0006-00-08-05-000 Page 10 of 33
2.6.1 Change the J-Link speed by following steps:
Right-click on the project name. In Figure 8 above the project name is
‘CEL_MAC_101_DP’. Select ‘Options…’ from the Menu List.
In the ‘J-Link/J-Trace’ category, set the ‘Reset’ to ‘Software’ and the ‘JTAG/SWD
speed’ to ‘Adaptive’ as shown in Figure 9.
Figure 9 – Screen, IAR Workbench – Setting JTAG/SWD Speed
2.7 OPTIMIZATIONS
Use of optimizations is up to the developer. For development and debugging it is strongly
encouraged to keep the optimization level at ‘None’ as shown in Figure 10.
Figure 10 – Screen, IAR Workbench – Optimizations

FreeStar Pro MAC Programmers’ Guide
Rev B 0006-00-08-05-000 Page 11 of 33
2.8 MAIN IAR FEATURES
2.8.1 Building a Project
Under the ‘Project’ menu several options exist to ‘Make’, ‘Compile’, or ‘Rebuild All’ code.
Figure 11 – Screen, IAR Workbench – Project Menu
2.8.2 Downloading into Flash:
Ensure J-Link is connected to PC though the USB cable.
Ensure FreeStar Pro Evaluation Board is connected to the J-Link though the ribbon
cable plugged into the JTAG Header (J1).
Ensure the power switch (SW6) is in the ON position as indicated by the red power
LED (D5) being illuminated.
Under the ‘Project’ menu select ‘Download and Debug’ as shown in Figure 12.

FreeStar Pro MAC Programmers’ Guide
Rev B 0006-00-08-05-000 Page 12 of 33
Figure 12 – Screen, IAR Workbench – Download and Debug
3 MAC Development with Sample Application
3.1 CODE DEVELOPMENT
The MC13224V is a powerful ARM7 based processor integrated with an IEEE 802.15.4
radio. Although the Sample Project provided does not exercise every available feature and
option, many software components for developing custom applications are included, such as:
Turning LED’s on and off with a timer.
De-bouncing switches.
Sending and receiving RF messages.
Using Analog to Digital Converters.
Using UART to send and receive data.
Using low power modes with different wakeup sources available.
Using Non-Volatile Memory.

FreeStar Pro MAC Programmers’ Guide
Rev B 0006-00-08-05-000 Page 13 of 33
3.2 Task Scheduler
Information about the Task Scheduler can be found in the IEEE 802.15.4 Media Access
Controller (MAC) MyWirelessApp User’s Guide.
3.2.1 Task Priority
Tasks are run based on priority. The list of default tasks can be found in
Application/Interface/Mac_Global.h file. Higher number priorities run first. A default
application main task named gTsAppTaskPriority_c (0x80) is already available and ready to
use, see Figure 13. Many applications can be built using just this task.
Figure 13 - Default Task Priorities
3.2.2 Adding a Task
If the user would like to separate certain software functions into another task, use the
TS_CreateTask function in the TS_kernel.c file found in the SSM\TS\Source directory. See
Figure 14 for an example of how to add a task. A description of the TS_CreateTask function
can be found in the TS_Interface.h file and is shown in Figure 15 for quick reference.
Figure 14 – Adding a Task
Figure 15 – Description of TS_CreateTask function

FreeStar Pro MAC Programmers’ Guide
Rev B 0006-00-08-05-000 Page 14 of 33
3.2.3 Task Events
Every task can have up to sixteen events in the form of a simple bitmask. The events are
passed into the task. The main tasks in the sample project are defined in
application_globals.h file. See Figure 16.
Figure 16 – Main Application Events
3.2.1 Sending an Event
To activate an event and therefore run the task scheduler, simply use the TS_SendEvent
Function. For example, if a UART message is received to put the device to sleep, an event
is set to run the main state machine. Note that the task ID assigned to the task in Figure 14
is an argument to the function, as well as the bitmask assigned the task in Figure 16.
Figure 17 – Sending an event.
The events are passed into the task. For example in the Main Application Tasks in Figure 16
are passed into the AppTask function. The function can then parse through the events to
see what event is active.
3.2.2 Clearing an Event
A similar function can be used to clear an event. Its name is TS_ClearEvent and is found in
the TS_kernal.c file. It has the same arguments as the TS_SendEvent function.
3.3 Timer Interface
The MAC software has an easy to use and powerful timer interface. The functions used to
interface to the timer are found in the Timer.c file.
3.3.1 Allocating a Timer
To allocate a timer use the TMR_AllocateTimer() function. For example the highlighted
section of Figure 18 shows four timers being allocated to the LED’s.
Figure 18 – Allocating a Timer
3.3.2 Starting a Single Shot Timer
Some timers may be set up to expire only once per setup. For example, an LED could be
turned on with a switch press and turned off with one of the timers allocated in Figure 18.
The timer only needs to expire once, not on a reoccurring basis. To accomplish this use the
TMR_ StartSingleShotTimer () function.
An example of this function is shown in Figure 19. This code initiates the LED flash
sequence on power up and can be found in theAppInit function. The arguments for the
function are the Timer ID assigned in Figure 18, the duration of the timer in mS, and the
function to call when the timer expires. In this application the LED1OnTimerEvent () function
simply turns off the LED.

FreeStar Pro MAC Programmers’ Guide
Rev B 0006-00-08-05-000 Page 15 of 33
Figure 19 – Starting a Single Shot Timer
3.3.3 Starting an Interval Timer
Some timers can be setup to expire on a periodic basis. To accomplish this use the
TMR_StartIntervalTimer() function. Its arguments are the same as those of a Single Shot
Timer.
3.4 Interfacing with the MAC
3.4.1 SAP Handlers
See the referenced Freescale documentation on SAP handlers. In the sample project they
can be found in the main_app.c file. Their purpose is to bring MAC messages to the
application level.
MLME type messages are network related messages.
MCPS type messages are RF-data related (sent or received a message).
Figure 20 – SAP Handlers
3.5 Sending and Receiving RF Messages
3.5.1 Setting Up Network
A handful of parameters need to be set up to operate on a network. These include:
RF Power (0-15)
RF Channel (channels 11-26)
Pan ID
Addressing Mode
Address
3.5.2 Changing RF Power
An API has been provided by Freescale to change the power. Its prototype is found in the
AppAspInterface.h file and can also be seen in Figure 21. Note that valid inputs to the
function are 0 to 15 (lowest power to highest power respectively). Generally speaking most
applications will only have to set the power level once (most likely to the highest power level)

FreeStar Pro MAC Programmers’ Guide
Rev B 0006-00-08-05-000 Page 16 of 33
during initialization.
Figure 21 – Changing RF Power
3.5.3 All other Network Parameters
The IEEE 802.15.4 is rich with features and options. Additional Freescale documentation
referenced in Error! Reference source not found. outline some of the IEEE 802.15.4
features. Using the concept of ‘having the right tool for the job’ a developer needs to decide
what features need to be implemented for the application.
The sample application provided includes attempts to demystify IEEE 802.15.4 by providing
straightforward point to point communication between devices. It uses a default PAN-ID of
0xBEEF, and short-addressing. A function called SetupNetwork () is included in the
application_mac.c file that sets up the other parameters. See Figure 22. Its arguments
include MAC-level acknowledgements being enabled, the device short-address, and the
channel.
The default PAN-ID can easily be changed. It is defined in application_mac.h – see Figure
23.

FreeStar Pro MAC Programmers’ Guide
Rev B 0006-00-08-05-000 Page 17 of 33
Figure 22 – Setting up other Network Parameters

FreeStar Pro MAC Programmers’ Guide
Rev B 0006-00-08-05-000 Page 18 of 33
Figure 23 – Changing the PAN-ID
3.5.4 Sending a RF Message
Once the network has been established (See 3.5.1) the device is ready to send a RF
message. A function called AppTransmitPacket() is included in the application_mac.c file
that will transmit a RF message and can also be seen in Figure 24. The parameters are
straightforward – require MAC level acknowledgement, source address, destination address,
message to send, and the number of bytes (how long) the message is.
Confirmation that the message has been sent will come from the MAC in the form of a
MCPS message. The AppTask() function in main_app.c checks for messages from the
MCPS, and will process accordingly. See Figure 25. The status byte will indicate if the
message was sent successfully.
Figure 24 – Sending a RF message

FreeStar Pro MAC Programmers’ Guide
Rev B 0006-00-08-05-000 Page 19 of 33
Figure 25 – MCPS message sent confirmation
3.5.5 Receiving a RF Message
Confirmation that the message has been sent will come from the MAC in the form of a
MCPS message. The AppTask() function in main_app.c checks for messages from the
MCPS, and will process accordingly. Figure 26 shows the processing of an RF message.
Only messages on the same PAN-ID, matching the destination address of the receiving
device are passed on to the application layer.
Figure 26 – Receiving a RF message

FreeStar Pro MAC Programmers’ Guide
Rev B 0006-00-08-05-000 Page 20 of 33
3.6 STATE DIAGRAMS
The following sections describe the states used in the Sample Project with the goal of
helping the user to understand the code, and how to modify it for a custom application.
3.6.1 Main State Diagram
Figure 27 – Diagram, Main State
Other manuals for ZFSM-201-EVB-1
1
Table of contents
Other CEL Motherboard manuals
Popular Motherboard manuals by other brands

Daniels Electronics Ltd.
Daniels Electronics Ltd. MT-3 Series instruction manual

Ublox
Ublox EVK-8 user guide

YIC Technologies
YIC Technologies EVK-YIC31612EBGG user guide

Contec
Contec GMB-C2165-LLVA user manual

Global American Inc.
Global American Inc. 2808000 user manual

BIG TREE TECH
BIG TREE TECH SKR Pico V1.0 Operation manual