Applications Engineering
EndDevice_Polling
Device will function as a ZigBee End Device but will only receive data from its
parent when the End Device asks (polls). This configuration would be used for a
battery-powered device that “sleeps” most of the time and only wakes up
periodically to check for new data (requires stack file
ZbRom_CC28_
RFD
_Vxx.mot
).
5.1.2. ZEK_Demo.c File
The file
ZEK_Demo.c
, in the
C:\Renesas\RZB_CC16C_ZDK\Sample_Code\ZEK_Demo\ZEK_Demo
directory, contains the C-source code for the entire ZEK demo application.
Reset Initialization
: After the MCU comes out of RESET, the RTOS and ZigBee stack are initialized and
then the user task function
app_task()
is called. This function would contain your user application code.
Program Flow
: In the ZEK Demo program, the
app_task()
function first initializes the MCU peripheral
and stack settings. Next, the ZDK board’s LCD prompts the user to choose the board’s ZigBee device
type by pressing the corresponding pushbutton below the displayed device type options. Once a button
press is detected, the function
MainLoop()
is called. The
MainLoop()
function implements a loop that
will never return for the life of the program.
Receiving New Data
: When a new ZigBee data packet is received, the function
AppDataIndication()
is called by the ZigBee stack. Because not much time should be spent in this
function, the payload of the data is saved in a circular receive buffer. In
MainLoop()
, the function
ProcessNewData()
is called periodically to deal with any new packets. The
ProcessNewData()
function calls the function
AppGetNextRxPacket()
to retrieve the data payloads that were saved in the
circular buffer by the
AppDataIndication()
function. It is recommended that you follow the same
procedure for processing new data.
Address Book
: After a node joins the network, it sends a message to the coordinator with its address.
The coordinator then adds that address to its address book, which it then broadcasts to every device in
the ZigBee network. You can send a ZigBee message to a specific device in the network by turning the
ZDK board’s potentiometer to scroll through the available list of addresses and selecting the address of
the desired destination device. If the selected destination address is the ZDK board’s own address, the
address will be changed to the network broadcast address 0xFFFF. The address book is not part of the
ZigBee specification; it is implemented in the ZEK Demo program simply as an application example.
5.1.3. Stack RAM Usage
Try to minimize the allocation of local variables that use stack space inside of functions. Remember that
your user application is running as a task in an RTOS with a limited amount of stack space allocated for it.
For this ZEK system, that value is fixed and cannot be changed. You must limit the RAM space used by
your local variables and function calls to less than 100 bytes.
5.1.4. Global Variable RAM Usage
You may create as many global variables for your user program as RAM space is available (896 bytes). A
virtual RAM section at the start of the debugger’s RAM has been created to warn you if you try to allocate
too much global RAM. Below is an example of the linker warning you will receive if you exceed the
available RAM space:
RZB-CC16C-ZDK User’s Manual Rev 1.1
11/ 39
December 2006