CEL ZFSM-201-EVB-1 Programmer's Manual

Free Star Pro Series
ZFSM-201-EVB-1
Evaluation Board
MAC Programmers’ Guide
ZFSM-201-1 FreeStar Pro Module

(Rev B)
FreeStar Pro MAC Programmers’ Gui de
TableofContents
1 OVERVIEW ......................................................................................................... 4
1.1 DESCRIPTION ............................................................................................ 4
1.2 REFERENCED DOCUMENTS .................................................................... 4
2 CODE DEVELOPMENT IN IAR WORKBENCH® .............................................. 5
2.1 TOOLS ......................................................................................................... 5
2.1.1IAR Embedded Workbench® for ARM .......................................................................... 5
2.1.2J-Link ............................................................................................................................... 6
2.2 PROJECT OVERVIEW ................................................................................ 6
2.2.1File Location on the CD ................................................................................................. 6
2.3 DEBUG/RELEASE WORKSPACE MODE .................................................. 7
2.4 APPLICATION FILES .................................................................................. 7
2.4.1Source Files .................................................................................................................... 7
2.4.2Utility files ....................................................................................................................... 8
2.5 PLM AND MAC SOURCE FILES ................................................................. 9
2.6 J-LINK SPEED ............................................................................................ 9
2.6.1Change the J-Link speed by following steps: ........................................................... 10
2.7 OPTIMIZATIONS ....................................................................................... 10
2.8 MAIN IAR FEATURES ............................................................................... 11
2.8.1Building a Project .......................................................................................................... 11
2.8.2Downloading into Flash: ............................................................................................... 11
3 MAC DEVELOPMENT WITH SAMPLE APPLICATION ................................... 12
3.1 CODE DEVELOPMENT ............................................................................ 12
3.2 TASK 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.3 TIMER INTERFACE ......................................................................................... 14
3.3.1Allocating a Timer ........................................................................................................ 14
3.3.2Starting a Single Shot Timer ....................................................................................... 14
3.3.3Starting an Interval Timer ............................................................................................ 15
3.4 INTERFACING WITH THE MAC ........................................................................ 15
3.4.1SAP Handlers ................................................................................................................ 15
3.5 SENDING 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
0006-00-08-05-000 Page 2 of 33
Rev B
FreeStar Pro MAC Programmers’ Gui de
Receiving a RF Message ............................................................................................. 19
3.5.5
3.6 STATE 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.7 RECEIVING A UART MESSAGE ............................................................... 32
3.8 TRANSMITTING A UART MESSAGE ....................................................... 32
3.9 TIMERS ..................................................................................................... 32
3.10 EVENTS..................................................................................................... 32
3.11READING ADC’S ....................................................................................... 32
3.12 USER INPUTS (SWITCHES) ..................................................................... 33
4 REVISION HISTOR Y ........................................................................................ 33
0006-00-08-05-000 Page 3 of 33
Rev B
FreeStar Pro MAC Programmers’ Gui de
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
BeeKit™ BeeKit™ BeeKit™
Rev B
Wireless Connectivity Toolkit Quick Start Guide BKWCTKQSG Wireless Connectivity Toolkit User’s Guide BKWCTKUG Wireless Connectivity Toolkit Software Release Notes BKWCTKRN
0006-00-08-05-000 Page 4 of 33
(www.freescale.com)
FreeStar Pro MAC Programmers’ Gui de
Document Title Document Name / Number MC13224V MC1322x MC1322x MC1322x
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
Note
found on the CEL Freestar Pro CD.
ZFSM-201-1 ZFSM-201-KIT-1 ZFSM-201-EVB-1 ZFSM-201-EVB-1 ZFSM-201-EVB-1 ZFSM-201-EVB-1 ZFSM-201-KIT-1 ZFSM-201-KIT-1, ZFSM-201-EVB-1 Note
Datasheet MC1322x Reference Manual MC1322xRM Software Driver Reference Manual 22XDRVRRM Simple Media Access Controller (SMAC) Reference Manual 22xSMACRM
Test Tool
: The Freescale documents listed above will be loaded to the user’s PC when installing the
Datasheet 0006-00-07-00-000
: The CEL documents listed above are included on the CEL CD.
User’s Guide TTUG
CEL Documents
Development Kit User Guide 0006-00-08-00-000
Evaluation Board Host Serial & RF Protocol Guide Evaluation Board SMAC Programmers Guide 0006-00-08-02-000 Evaluation Board BeeKit™ Porting Guide Evaluation Board MAC Programmers Guide 0006-00-08-05-000
Wireless UART Application User Guide
Erratum 0006-00-08-04-000
(www.cel.com)
0006-00-08-01-000 0006-00-08-03-000 0006-00-08-06-000
BeeKit™
Toolkit
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 The included MAC project on the CD was developed in IAR Embedded Workbench®
www.iar.com for details.
for ARM version 5.20.
0006-00-08-05-000 Page 5 of 33
Rev B
2.1.2 J-Link
FreeStar Pro MAC Programmers’ Gui de
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
0006-00-08-05-000 Page 6 of 33
Rev B
FreeStar Pro MAC Programmers’ Gui de
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 – Applica tio n 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 BeeKit™ from the Freescale website.
Error! Reference source not found.
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.
0006-00-08-05-000 Page 7 of 33
Rev B
. For the latest Freescale codebase, please download the Freescale
FreeStar Pro MAC Programmers’ Gui de
application_mac.c - This code contains the base applications for the CEL/MAC
release:
o Range test
o Packet error rate test
o Continuous receive
o Psuedo 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
The UartUtil module included with the project when made by BeeKit™ is located in the
‘Applications folder as shown in Figure 6.
0006-00-08-05-000 Page 8 of 33
Rev B
Figure 6 – Utility Source Files
FreeStar Pro MAC Programmers’ Gui de
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
0006-00-08-05-000 Page 9 of 33
Rev B
FreeStar Pro MAC Programmers’ Gui de
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
0006-00-08-05-000 Page 10 of 33
Rev B
FreeStar Pro MAC Programmers’ Gui de
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.
0006-00-08-05-000 Page 11 of 33
Rev B
FreeStar Pro MAC Programmers’ Gui de
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.
0006-00-08-05-000 Page 12 of 33
Rev B
FreeStar Pro MAC Programmers’ Gui de
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) i s 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
0006-00-08-05-000 Page 13 of 33
Rev B
FreeStar Pro MAC Programmers’ Gui de
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 Ti mer
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 the AppInit 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.
0006-00-08-05-000 Page 14 of 33
Rev B
FreeStar Pro MAC Programmers’ Gui de
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).
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)
0006-00-08-05-000 Page 15 of 33
Rev B
Figure 20 – SAP Handlers
during initialization.
FreeStar Pro MAC Programmers’ Gui de
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.
0006-00-08-05-000 Page 16 of 33
Rev B
FreeStar Pro MAC Programmers’ Gui de
Figure 22 – Setting up other Network Parameters
0006-00-08-05-000 Page 17 of 33
Rev B
FreeStar Pro MAC Programmers’ Gui de
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.
0006-00-08-05-000 Page 18 of 33
Rev B
Figure 24 – Sending a RF message
FreeStar Pro MAC Programmers’ Gui de
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.
0006-00-08-05-000 Page 19 of 33
Rev B
Figure 26 – Receiving a RF message
FreeStar Pro MAC Programmers’ Gui de
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
0006-00-08-05-000 Page 20 of 33
Rev B
Figure 27 – Diagram, Main State
3.6.2 AppInit State Diagram
FreeStar Pro MAC Programmers’ Gui de
0006-00-08-05-000 Page 21 of 33
Rev B
Figure 28 – Diagram, AppInit State
FreeStar Pro MAC Programmers’ Gui de
3.6.3 Transmit/Receive RF Message State Diagram
Figure 29 – Diagram, Transmit/Receive Message State
0006-00-08-05-000 Page 22 of 33
Rev B
FreeStar Pro MAC Programmers’ Gui de
3.6.4 PERT Transmit Message State Diagram
PERT Transmit
INIT_PERT_TX State
-Setup Radio
-Setup PERT Message
NO
TRANSMITTING_PERT State
Figure 30 – Diagram, PERT Transmit Message State
NO
Done Transmitting
Message?
YES
All Messages Sent?
YES
DONE
0006-00-08-05-000 Page 23 of 33
Rev B
FreeStar Pro MAC Programmers’ Gui de
3.6.5 Hibernate using 2kHz Oscillator State Diagram
Figure 31 – Diagram, Hibernate using 2kHz Oscillator State
0006-00-08-05-000 Page 24 of 33
Rev B
FreeStar Pro MAC Programmers’ Gui de
3.6.6 Hibernate using 32kHz Oscillator State Diagram
Figure 32 – Diagram, Hibernate using 32kHz Oscillator State
0006-00-08-05-000 Page 25 of 33
Rev B
FreeStar Pro MAC Programmers’ Gui de
3.6.7 Doze using 24MHz Reference Oscillator State Diagram
Figure 33 – Diagram, Doze using 24MHz Oscillator State
0006-00-08-05-000 Page 26 of 33
Rev B
FreeStar Pro MAC Programmers’ Gui de
3.6.8 Enable Buck Regulator State
Figure 34 – Diagram, Enable Buck Regulator State
0006-00-08-05-000 Page 27 of 33
Rev B
3.6.9 Save to NVM State Diagram
FreeStar Pro MAC Programmers’ Gui de
Figure 35 – Diagram, Save to NVM State
0006-00-08-05-000 Page 28 of 33
Rev B
FreeStar Pro MAC Programmers’ Gui de
3.6.10 NVM Read State Diagram
Figure 36 – Diagram, NVM Read State
0006-00-08-05-000 Page 29 of 33
Rev B
FreeStar Pro MAC Programmers’ Gui de
3.6.11 UART Receive State Diagram
Figure 37 – Diagram, UART Receive State
0006-00-08-05-000 Page 30 of 33
Rev B
FreeStar Pro MAC Programmers’ Gui de
3.6.12 Reading ADC’s State Diagram
Figure 38 – Diagram, Reading ADC’s State
0006-00-08-05-000 Page 31 of 33
Rev B
FreeStar Pro MAC Programmers’ Gui de
3.7 RECEIVING A UART MESSAGE
UART messages are parsed as they are received with the use of function pointers.
Each state of the function checks for valid data (start byte, message type, checksum
and end-of-frame).
If a valid UART message is received another function pointer is set up based on the
message Type.
This function will respond as appropriate for the message type and received data. See uart_parse.c
3.8 TRANSMITTING A UART MESSAGE
The MC13224V has an internal 32-byte transmit buffer.
Data is fed into the buffer and as interrupts occur, the application code waits for the
buffer to empty.
See uart_parse.c and the UartIsr1A function in main_state.c.
3.9 TIMERS
A variety of options exist on the MC13224V for periodic timers that expire and generate an interrupt.
The sample SMAC project on the CD uses Timer0 to generate an interrupt every 5mS. See timers.c for setup and usage. A variety of the other timers based on Timer0 can be set up and updated every time
Timer0 expires. See the UpdateTimer0() function in main_state.c.
3.10 EVENTS
Low priority events (turn LED’s off, responding to switches) are handled in the
EventDo() function in main_state.c.
Other events can be easily added.
3.11 READING ADC’S
Two A/D converters are connected to Potentiometers on the CEL ZFSM-201-EVB-1
FreeStar Pro Evaluation Board.
Another A/D internal to the MC13224V can be used to monitor the battery voltage. It is important to monitor the battery voltage when the Buck Regulator is active. If the
battery voltage falls below 2.5V the Buck needs to be placed in bypass mode. See Freescale Semiconductors’
When a GUI message is received to query the A/D channels a Timer is set up to read
the A/D’s every 500mS.
The ADC_Setup() function in main_state.c sets up the A/D’s. Although the battery is used as the A/D reference, its value is based on an internal
1.2V reference.
Value read back by the 9 To obtain the actual power supply use the following formula:
o Power Supply Voltage = (4095*1.20)/Power Supply A/D result
“MC1322x Reference Manual”
th
A/D input (battery) is actually a 1.20V reference.
(Freescale Doc # MC1322xRM)
.
0006-00-08-05-000 Page 32 of 33
Rev B
FreeStar Pro MAC Programmers’ Gui de
This ‘adjusted’ Power Supply Value can be used to improve the accuracy of the A/D
values obtained from the power supply.
o ADC Voltage = (A/D result /4095) * Power Supply Voltage
3.12 USER INPUTS (SWITCHES)
When an interrupt is detected on a switch, a 25mS Timer based off Timer0 is started.
Upon expiration the switch input to the MC13224V is read. If it is low (pressed) a valid switch press flag is set. The EventDo () function in main_state.c will respond to the switch event.
4 REVISION HISTORY
Revision Date Description
A 04Feb09 Released B 22May09 Updated for BeeKit v1.9.5 / MAC v1.11
0006-00-08-05-000 Page 33 of 33
Rev B
Loading...