Professional Documents
Culture Documents
Application Note
AN2707
Rev. 0, 4/2004
By John Logan
Freescale Semiconductor, Inc...
8/16-Bit Division
East Kilbride, Scotland
Introduction
This application note describes a set of software drivers for the MC33493 RF
transmitter (codename Tango3) and the MC33591/2/3/4 RF receiver ICs
(codename Romeo2). The drivers are designed to allow a designer to quickly
develop a new application using these RF ICs with minimum effort, or to add
RF functionality to an existing design. The drivers are written in the C
programming language. The Tango3 driver can be configured to use any
HCS08 MCU. The Romeo2 driver can be configured to use any HC08 MCU
with an SPI interface. Each driver allows the user to select different MCU I/O
pins, timer channels, and clocking options, to allow easy implementation. Full
source code listings and example applications are available from Motorola's
web site at http://e-www.motorola.com.
This document makes frequent references to the Tango3 and Romeo2 device
datasheets; the reader should read these documents before using these
drivers. Both datasheets are available for download from Motorola's web site at
http://e-www.motorola.com.
Contents
Page
Introduction ................................................................................................................. 1
Contents ..................................................................................................................... 2
Communication Concept ............................................................................................ 3
Message Formats ....................................................................................................... 4
Sending Messages With Header Detect .............................................................. 5
Sending Messages Without Header Detect ......................................................... 5
Reducing Power Consumption ............................................................................. 6
Tone Signalling .................................................................................................... 7
Freescale Semiconductor, Inc...
2 Software Drivers for Tango3 RF Transmitter and Romeo2 RF Receiver ICs MOTOROLA
For More Information On This Product,
Go to: www.freescale.com
Freescale Semiconductor, Inc.
AN2707
Communication Concept
Communication Concept
Figure 1 shows a simple example lighting network with three lighting fixtures
(each with a Romeo2 receiver) and one remote control (with a Tango3
Freescale Semiconductor, Inc...
Lamp
HC08
=
MCU
0x
30
Lamp
Keypad
Lamp
ID = 0x30
MOTOROLA Software Drivers for Tango3 RF Transmitter and Romeo2 RF Receiver ICs 3
For More Information On This Product,
Go to: www.freescale.com
Freescale Semiconductor, Inc.
AN2707
Message Formats
The drivers support the messaging formats defined in the Romeo2 datasheet.
Communications using ID or tone signalling, with or without the header field are
supported.
NOTE: The Romeo2 driver uses Romeo2's on-board data manager hardware.
The drivers extend the message formats shown in the datasheet, by defining
length, data and checksum fields for each message.
Freescale Semiconductor, Inc...
NOTE: The ID word must not contain the bit sequences '0110' or '1001'. These bit
sequences are used as the header word field. See the Romeo2 datasheet for
more detailed information.
Header — The Header field is a 4-bit fixed format field. It notifies Romeo2 that
message data is next. The header field is fixed to '0110' in this driver
implementation. When Romeo2 receives the Header byte, it expects to receive
the Length and Data fields next. It is possible to send messages with or without
this field.
Length — The Length field is a byte containing the length of the Data field.
EOM (End of Message) — The EOM field is a fixed format field that indicates
the end of a message.
4 Software Drivers for Tango3 RF Transmitter and Romeo2 RF Receiver ICs MOTOROLA
For More Information On This Product,
Go to: www.freescale.com
Freescale Semiconductor, Inc.
AN2707
Message Formats
NOTE: Preamble, Header, Checksum and EOM are handled by the software drivers;
the application programmer does not have to specify these fields.
Sending Messages Figure 2 shows a message frame transmitted by Tango3 and the received data
With Header Detect that Romeo2 passes to the MCU using its SPI interface. Tango3 transmits a
Preamble then the ID field. When Romeo2 receives a valid ID, it will wait to
receive a Header field. When it receives a Header, it then expects to receive
Length, Data, Checksum and EOM fields. While waiting for the Header field, it
will ignore all other data. Note that its possible to have a delay between the ID
Freescale Semiconductor, Inc...
Using this message format, Romeo3 does not pass the ID field to the MCU on
the SPI interface. It passes only the Length, Data and Checksum fields. This
reduces the load on the SPI interface.
It is also possible to repeat the Preamble and ID fields multiple times. This is
discussed below.
Generated by driver
Supplied by application/programmer
Sending Messages The header field is used to determine the start of the Length field. Romeo2
Without Header transmits all data, received after the header field, on its SPI interface, typically
Detect to an MCU. However, it is possible to send messages without using the header
field.
MOTOROLA Software Drivers for Tango3 RF Transmitter and Romeo2 RF Receiver ICs 5
For More Information On This Product,
Go to: www.freescale.com
Freescale Semiconductor, Inc.
AN2707
it will pass all following data to the MCU via the SPI interface. See Figure 3. If
the ID field is repeated, this will mean that ID bytes are also passed to the MCU.
This message format requires more CPU time to decode the received data,
since it must handle the ID field.
Key ID detected
Generated by driver
Supplied by application/programmer
Reducing Power To reduce power consumption in the system, the drivers can utilize two
Consumption features of the Romeo2 device: the strobe oscillator; and the ability to repeat
the ID field. The Romeo2 datasheet includes a full description of the strobe
oscillator function.
The strobe oscillator function cycles Romeo2 between the very low power
SLEEP mode and a RUN mode, thereby reducing the total current
consumption. As mentioned previously, it is possible to repeat the Preamble
and ID sections of the message. If Tango3 transmits a sequence of short
Preamble + ID messages over a period longer than the strobe oscillator’s
SLEEP period, Romeo2 will detect at least one of these messages in RUN
mode. When this has been detected, Romeo2 will override its Strobe oscillator,
and will remain in RUN mode until it receives the remaining message fields.
Figure 4 shows the sequence.
6 Software Drivers for Tango3 RF Transmitter and Romeo2 RF Receiver ICs MOTOROLA
For More Information On This Product,
Go to: www.freescale.com
Freescale Semiconductor, Inc.
AN2707
Message Formats
Tone Signalling Tone signalling is used in systems where all the receiver nodes must wake up
and check each RF message. For example, in the simple lighting network
shown in Figure 1, it could be desirable to control all the lights simultaneously.
To do this, each node is assigned an ID of 0x00 or 0xff (i.e., the ID is all '1's or
all '0''s). Then, all receivers will accept each message sent at the same time.
Figure 5 shows a message frame with Tone signalling. The Romeo2 IC
supports Tones of any length greater than eight bits. This software driver allows
the user to set the length of a Tone to multiples of eight bits by repeating the ID
field multiple times
Generated by driver
Supplied by application/programmer
Message Encoding Figure 6 shows the flow of data and the encoding stages for a message
transfer.
For Tango3 to transmit a message, the application must provide the ID, length
and Data fields of the message in a transmit buffer and call the correct driver
routines. The software driver reads the message from this buffer and the
message is encoded using the Manchester coding method prior to
transmission. The message is then transmitted using Frequency Shift Keying
MOTOROLA Software Drivers for Tango3 RF Transmitter and Romeo2 RF Receiver ICs 7
For More Information On This Product,
Go to: www.freescale.com
Freescale Semiconductor, Inc.
AN2707
HC08 CPU
HC08 CPU
Romeo2
Freescale Semiconductor, Inc...
Driver writes
Driver reads
msg to buffer
Msg from buffer
Manchester For Tango3 to transmit RF data, it must be supplied with a bitstream containing
Encoding the data in Manchester encoded format. A Manchester encoded bit is
represented by a sequence of two opposite logic levels. A '0' bit of data is
encoded as sequence '01', a '1' bit of data is encoded as sequence '10'. Figure
7 shows what will be seen on Tango3's DATA input when transmitting the data
sequence '11001' using Manchester encoding. Note that there is always a level
transition in the middle of a bit, but not always a transition on a bit boundary.
On the MCU, a timer I/O pin with an output compare function is used to
generate each bit. The timer modulus (or timebase) is set to match the
timebase of the Manchester encoded data. The output compare function is set
to half the timebase. By controlling the level of the I/O pin when output compare
occurs or the timer 'rolls over' to zero, the driver can generate the correct
sequence. Figure 7 shows the relationship between the timer counter value
and the generated output.
8 Software Drivers for Tango3 RF Transmitter and Romeo2 RF Receiver ICs MOTOROLA
For More Information On This Product,
Go to: www.freescale.com
Freescale Semiconductor, Inc.
AN2707
Tango3 Driver
1 1 0 0 1
Bit Decoding Romeo2's built-in data manager decodes the Manchester encoded data
internally. It transmits decoded bits on its SPI interface.
Tango3 Driver
Tango3 Hardware Figure 8 shows the interface between the Tango3 IC and an MCU.
Connections
MOTOROLA Software Drivers for Tango3 RF Transmitter and Romeo2 RF Receiver ICs 9
For More Information On This Product,
Go to: www.freescale.com
Freescale Semiconductor, Inc.
AN2707
ENABLE
I/O pin
MCU
DATACLK
Freescale Semiconductor, Inc...
3V
BAND
MODE
A description of each connection between the MCU and Tango3 is given below.
ENABLE — When this signal is at logic 1, the Tango3 IC is enabled and can
transmit data. When this signal is logic 0, Tango3 is disabled and placed in a
low power consumption mode.
DATACLK — This signal allows Tango3 to provide the MCU with an accurate
clock signal, which can be used as an accurate timebase for generating data
bits for transmission. This is useful with MCUs that use a low-accuracy clock
source, such as, for example, an RC oscillator. When Tango3 is enabled
(ENABLE = 1), DATACLK is active; when Tango3 is disabled (ENABLE = 0),
DATACLK is at logic 0.
10 Software Drivers for Tango3 RF Transmitter and Romeo2 RF Receiver ICs MOTOROLA
For More Information On This Product,
Go to: www.freescale.com
Freescale Semiconductor, Inc.
AN2707
Tango3 Driver
BAND — This signal sets the operating band for Tango3, which defines the RF
carrier frequency. This signal is usually hard-wired to a particular value but can
also be controlled by the MCU. At logic 1, the RF carrier frequency is set to 32
times the Tango3 crystal frequency; at logic 0, the RF carrier frequency is set
to 64 times the Tango3 crystal frequency.
The software driver can be configured to use or ignore BAND. BAND can be
hard-wired to Vdd or ground if the carrier frequency is fixed.
NOTE: Pull-up or pull-down resistors are required only if the MCU is required to
override the hard-wired values.
MODE — This signal sets the modulation mode for Tango3. This signal is
Freescale Semiconductor, Inc...
usually hard-wired to a particular value, but can also be controlled by the MCU.
When MODE is at logic 1, FSK modulation is selected; when MODE is at logic
0, OOK modulation is selected.
The software driver can be configured to use or ignore MODE. MODE can be
hard-wired to Vdd or ground if the modulation mode is fixed.
NOTE: Pull-up or pull-down resistors are required only if the MCU is required to
override the hard-wired values.
Tango3 MCU The Tango3 driver requires the following minimum MCU resources.
Resources
• One timer channel and its associated I/O pin used in output compare
mode. The interrupt vector for this timer channel will also be used. The
timer channel is connected to Tango3's DATA pin.
The Tango3 driver will set the modulus value for the timer associated
with the timer channel chosen.
• One I/O pin connected to Tango3's ENABLE pin. This allows the MCU
to enable/disable Tango3, which can be useful for reducing current
consumption in an application. Alternatively, the designer could tie the
ENABLE pin directly to Vdd to permanently enable Tango3.
MOTOROLA Software Drivers for Tango3 RF Transmitter and Romeo2 RF Receiver ICs 11
For More Information On This Product,
Go to: www.freescale.com
Freescale Semiconductor, Inc.
AN2707
• One I/O pin connected to Tango3’s ENABLEPA pin. (Note: This pin is
provided for use with Motorola's Tango3 RF module, which features an
on-board power amplifier.)
Tango3 Driver This section provides a description of the Tango3 driver application interface
Description and run-time services.
The Tango3 driver provides a set of runtime services using C function calls that
allow the user to transmit messages. The services are listed below.
Messages are constructed in a RAM buffer prior to transmission. The driver can
send messages with or without a Header field as describes in Sending
Messages With Header Detect on page 5 and Sending Messages Without
Header Detect on page 5. Figure 10 shows a flowchart for sending a message
with a header field, Figure 11 shows a flowchart for sending a message without
a header field.
12 Software Drivers for Tango3 RF Transmitter and Romeo2 RF Receiver ICs MOTOROLA
For More Information On This Product,
Go to: www.freescale.com
Freescale Semiconductor, Inc.
AN2707
Tango3 Driver
The Tango3 driver defines a transmission buffer in RAM. The MCU writes
messages to the buffer, and the driver reads messages from this buffer and
transmits them on the RF link. The buffer contains the message ID, Length and
Data fields as shown in Figure 9. Note storage for the checksum field is not
required. The Tango3 driver generates the checksum field internally and
appends it to the message during transmission.
The size of the buffer can be programmed by the user, using the
TANGO_MAX_DATA_SIZE parameter in the Tango.H header file. The buffer
should be made large enough to receive the largest message being
transferred. See TANGO_MAX_DATA_SIZE on page 22 for details.
The application must not write to the transmission buffer while a message is
Freescale Semiconductor, Inc...
7 4 3 0
$xxxx ID
Length
Data0
...
...
...
Data127
Internal processing of the driver occurs when the main application calls any of
the run-time services, or after transmission of each bit when the driver is
transmitting a message. Since transmission of each bit is controlled by a timer
channel interrupt on the MCU, the user must link the TangoTimerInterrupt
service to the timer channel interrupt. An example of this is shown in Adding
the Tango3 Driver to an Application on page 27.
MOTOROLA Software Drivers for Tango3 RF Transmitter and Romeo2 RF Receiver ICs 13
For More Information On This Product,
Go to: www.freescale.com
Freescale Semiconductor, Inc.
AN2707
Start
Call TangoInitialise to
initilise driver
Call TangoEnable to Y
power up Tango3
Call TangoSendData
Freescale Semiconductor, Inc...
N
Driver status
== Y
TANGO_READY? Want to send
another message ?
Y
N
Call TangoSendPreamble_ID
Call TangoDisable
N
Driver status
==
End
TANGO_READY?
Decrement IDRepeat
N
IDRepeat
== 0 ?
14 Software Drivers for Tango3 RF Transmitter and Romeo2 RF Receiver ICs MOTOROLA
For More Information On This Product,
Go to: www.freescale.com
Freescale Semiconductor, Inc.
AN2707
Tango3 Driver
Start
Call TangoInitialise to
initilise driver
Call TangoEnable to
power up Tango3
Freescale Semiconductor, Inc...
N
Driver status
==
TANGO_READY?
Call TangoSendMessageNoHeader
With correct number of ID repeats
N
Driver status
==
TANGO_READY?
Y
Want to send
another message ?
Call TangoDisable
End
MOTOROLA Software Drivers for Tango3 RF Transmitter and Romeo2 RF Receiver ICs 15
For More Information On This Product,
Go to: www.freescale.com
Freescale Semiconductor, Inc.
AN2707
After the driver has been initialized, it can be in one of four states.
Figure 12 shows the various states the driver will return when the
TangoDriverStatus service is called.
Freescale Semiconductor, Inc...
Call
TangoInitialise()
MUST DO THIS
TO INITIALISE
DRIVER!!
TANGO_DISABLED
Call TangoEnable()
Call TangoDisable()
TANGO_IN_
ENABLE_DELAY
Call TangoDisable()
TANGO_READY
End of
TangoSendPreamble_ID,
TangoSendData or Call TangoSendPreamble_ID or
TangoSendMessageNoHeader TangoSendData or
TangoSendMessageNoHeader
TANGO_BUSY
Call TangoDisable()
16 Software Drivers for Tango3 RF Transmitter and Romeo2 RF Receiver ICs MOTOROLA
For More Information On This Product,
Go to: www.freescale.com
Freescale Semiconductor, Inc.
AN2707
Tango3 Driver
Tango3 Driver This section provides descriptions of each service provided by the Tango3
Services driver.
TangoInitialise
TangoEnable
MOTOROLA Software Drivers for Tango3 RF Transmitter and Romeo2 RF Receiver ICs 17
For More Information On This Product,
Go to: www.freescale.com
Freescale Semiconductor, Inc.
AN2707
TangoDisable
TangoDriverStatus
18 Software Drivers for Tango3 RF Transmitter and Romeo2 RF Receiver ICs MOTOROLA
For More Information On This Product,
Go to: www.freescale.com
Freescale Semiconductor, Inc.
AN2707
Tango3 Driver
TangoSendPreamble_ID
TangoSendData
MOTOROLA Software Drivers for Tango3 RF Transmitter and Romeo2 RF Receiver ICs 19
For More Information On This Product,
Go to: www.freescale.com
Freescale Semiconductor, Inc.
AN2707
TangoSendMessageNoHeader
TangoTimerInterrupt
Tango3 Driver The Tango3 driver has a static configuration at compile time. Its configuration
Configuration cannot be changed during run time. The driver configuration is defined in a
header file Tango.H. Configuration options are available for the following.
• Message format
• Message data rate
• Message modulation format (OOK or FSK)
• Carrier frequency
• MCU resources
20 Software Drivers for Tango3 RF Transmitter and Romeo2 RF Receiver ICs MOTOROLA
For More Information On This Product,
Go to: www.freescale.com
Freescale Semiconductor, Inc.
AN2707
Tango3 Driver
When starting a project using the Tango3 driver, the files ‘Tango.H’ and
‘Tango.C’ should be placed in the project directory, and a #include ‘Tango.H’
statement should be inserted in the main application file.
TANGO_TIMER_ADDRESS
Description: This defines the address of the timer status and control
register, in the MCU's memory map. The timers on all
HCS08 MCUs have the same layout of control registers.
The driver uses this base address to access the timer
control registers.
Values: Address in range 0x0000 - 0xffff
Example:
#define TANGO_TIMER_ADDRESS 0x30 /* 1st timer register at address 0x30*/
TANGO_TIMER_CHANNEL
Description: This defines the timer channel used to output data on the
DATA line.
Values: Channel number in the range 0–15.
Example:
#define TANGO_TIMER_CHANNEL 1 /* Use timer channel 1 */
MOTOROLA Software Drivers for Tango3 RF Transmitter and Romeo2 RF Receiver ICs 21
For More Information On This Product,
Go to: www.freescale.com
Freescale Semiconductor, Inc.
AN2707
TANGO_MAX_DATA_SIZE
Description: This defines the maximum number of data bytes that can
be transferred. This value is used to calculate the size of
the message transmit buffer. (The transmit buffer will be
TANGO_MAX_DATA_SIZE + 2 bytes.)
Values: Number in range 0–127.
Example:
#define TANGO_MAX_DATA_SIZE 8 /* Max size of data field = 8 bytes*/
Freescale Semiconductor, Inc...
TANGO_TIMER_CLOCK_SOURCE
TANGO_TIMER_CLOCK_SPEED
22 Software Drivers for Tango3 RF Transmitter and Romeo2 RF Receiver ICs MOTOROLA
For More Information On This Product,
Go to: www.freescale.com
Freescale Semiconductor, Inc.
AN2707
Tango3 Driver
TANGO_TIMER_PRESCALE
Description: This defines the prescaler value of the timer used to send
data to Tango3. Generally this will be set to ‘1’. (Note: If
an external clock source is being used, this value will be
forced to ‘1’ by the driver.)
Values: See datasheet for S08 MCU.
Example:
#define TANGO_TIMER_PRESCALE 1 /* Specify timer prescaler value */
Freescale Semiconductor, Inc...
TANGO_TIMER_DISABLE
Description: This allows the driver to switch off the MCU timer when it
is not required to drive Tango3. This can reduce power
consumption. However, in some applications it may be
required that the timer continue running. (Note: The driver
will always start the timer when it is required.)
Values: 0 = Timer remains running after transmission of data.
1 = Timer is disabled after transmission of data.
Example:
#define TANGO_TIMER_DISABLE 1 /* Allows driver to turn off timer after use */
TANGO_MODE_VALUE
MOTOROLA Software Drivers for Tango3 RF Transmitter and Romeo2 RF Receiver ICs 23
For More Information On This Product,
Go to: www.freescale.com
Freescale Semiconductor, Inc.
AN2707
TANGO_BAND_VALUE
TANGO_CRYSTAL_FREQUENCY
Description: This defines the speed (in Hz) of the crystal used by the
Tango3 IC.Typical values at supported RF frequencies
are:
TANGO_DATA_RATE
24 Software Drivers for Tango3 RF Transmitter and Romeo2 RF Receiver ICs MOTOROLA
For More Information On This Product,
Go to: www.freescale.com
Freescale Semiconductor, Inc.
AN2707
Tango3 Driver
TANGO_ENABLE
Description: This defines the I/O pin used to control Tango3's ENABLE
pin. If ENABLE is not controlled by the MCU in your
system, delete this #define from the header file.
Values: Any I/O pin configurable as an output can be used. Use
the naming convention specified in the CodeWarrior
header files.
Example:
Freescale Semiconductor, Inc...
TANGO_ENABLE_DDR
Description: This defines the data direction bit for the I/O pin used to
control Tango3's Enable pin. If Enable is not controlled by
the MCU in your system, delete this #define from the
header file.
Values: Any I/O pin configurable as an output can be used. Use
the naming convention specified in the CodeWarrior
header files.
Example:
#define TANGO_ENABLE_DDR PTADD_PTADD0 /* DDR for Port A pin 0 */
MOTOROLA Software Drivers for Tango3 RF Transmitter and Romeo2 RF Receiver ICs 25
For More Information On This Product,
Go to: www.freescale.com
Freescale Semiconductor, Inc.
AN2707
TANGO_MODE
Description: This defines the I/O pin used to control Tango3's MODE
pin. If MODE is not controlled by the MCU in your system,
delete this #define from the header file.
Values: Any I/O pin configurable as an output can be used. Use
the naming convention specified in the CodeWarrior
header files.
Example:
Freescale Semiconductor, Inc...
TANGO_MODE_DDR
Description: This defines the data direction bit for the I/O pin used to
control Tango3's MODE pin. If MODE is not controlled by
the MCU in your system, delete this #define from the
header file.
Values: Any I/O pin configurable as an output can be used. Use
the naming convention specified in the CodeWarrior
header files.
Example:
#define TANGO_MODE_DDR PTADD_PTADD1 /* DDR for PortA pin 1 */
TANGO_BAND
Description: This defines the I/O pin used to control Tango3's BAND
pin. If BAND is not controlled by the MCU in your system,
delete this #define from the header file.
Values: Any I/O pin configurable as an output can be used. Use
the naming convention specified in the CodeWarrior
header files.
Example:
#define TANGO_BAND PTAD_PTAD2 /* Port A pin 2 */
26 Software Drivers for Tango3 RF Transmitter and Romeo2 RF Receiver ICs MOTOROLA
For More Information On This Product,
Go to: www.freescale.com
Freescale Semiconductor, Inc.
AN2707
Adding the Tango3 Driver to an Application
TANGO_BAND_DDR
Description: This defines the data direction bit for the I/O pin used to
control Tango3's BAND pin. If BAND is not controlled by
the MCU in your system, delete this #define from the
header file.
Values: Any I/O pin configurable as an output can be used. Use
the naming convention specified in the CodeWarrior
header files.
Example:
Freescale Semiconductor, Inc...
Figure 15 shows an example Tango.H header file. This has been configured
for use with an MC9S08GB60 MCU. Tango3 is configured for 434 MHz
operation with a data rate of 1 kbps. Timer 0, channel 1 is used on the MCU.
MOTOROLA Software Drivers for Tango3 RF Transmitter and Romeo2 RF Receiver ICs 27
For More Information On This Product,
Go to: www.freescale.com
Freescale Semiconductor, Inc.
AN2707
Freescale Semiconductor, Inc...
TangoTransmitBuffer[]
Tango.H file declaration
28 Software Drivers for Tango3 RF Transmitter and Romeo2 RF Receiver ICs MOTOROLA
For More Information On This Product,
Go to: www.freescale.com
Freescale Semiconductor, Inc.
AN2707
Adding the Tango3 Driver to an Application
Freescale Semiconductor, Inc...
TangoTimerInterrupt entry
MOTOROLA Software Drivers for Tango3 RF Transmitter and Romeo2 RF Receiver ICs 29
For More Information On This Product,
Go to: www.freescale.com
Freescale Semiconductor, Inc.
AN2707
/****************************************************************************************/
/* THIS SECTION CONTAINS VALUES YOU MUST DEFINE! */
/* */
#include <MC9S08GB60.h> /* Include peripheral declarations */
/****************************************************************************************/
/* These may be omitted depending on the hardware setup */
30 Software Drivers for Tango3 RF Transmitter and Romeo2 RF Receiver ICs MOTOROLA
For More Information On This Product,
Go to: www.freescale.com
Freescale Semiconductor, Inc.
AN2707
Using the Tango3 Driver in an Application
The application can check the current state of the driver by calling
TangoStatus().
Figure 15 shows the contents of the Tango.h file for this example.
MOTOROLA Software Drivers for Tango3 RF Transmitter and Romeo2 RF Receiver ICs 31
For More Information On This Product,
Go to: www.freescale.com
Freescale Semiconductor, Inc.
AN2707
Freescale Semiconductor, Inc...
32 Software Drivers for Tango3 RF Transmitter and Romeo2 RF Receiver ICs MOTOROLA
For More Information On This Product,
Go to: www.freescale.com
Freescale Semiconductor, Inc.
AN2707
Romeo2 Driver
Romeo2 Driver
Romeo2 Hardware Figure 17 shows the interface between the Romeo2 IC and an MCU.
Connection
Freescale Semiconductor, Inc...
STROBE
MCU
ROMEO
RESETB
RESETB
SCLK
SCLK MOSI SCLK
MOSI MOSI
MISO MISO MISO
SS
Required
Optional
MOSI, MISO, SCLK — These are SPI data and clock connections. The SPI link
allows the MCU to configure Romeo2, and also allows Romeo2 to pass data
received on the RF link to the MCU.
RESETB — This signal controls the state of Romeo2 and the direction of data
on the SPI interface. When RESETB is at logic 0, Romeo2 is a slave on the SPI
link; the MCU can write or read data to or from Romeo2’s internal registers.
When RESETB is logic 1, Romeo2 is the master on the SPI bus; it sends data
received on RF to the MCU via the SPI.
SS (Slave Select) — This pin on the MCU must be held low when the MCU is
configured as an SPI slave. In most systems, this pin will be tied to ground
using a pull-down resistor.
MOTOROLA Software Drivers for Tango3 RF Transmitter and Romeo2 RF Receiver ICs 33
For More Information On This Product,
Go to: www.freescale.com
Freescale Semiconductor, Inc.
AN2707
Romeo2 Driver This section provides a description of the Romeo2 driver application interface
Description and run-time services.
The Romeo2 driver provides a set of runtime services using C function calls
that allow the user to receive messages. The services are listed below.
RomeoSPIRxInt — Provides the driver with a link to the MCU's SPI interface
receive interrupt.
The Romeo2 driver defines a receive buffer in RAM. The Romeo2 driver writes
complete messages to this buffer after reception from the RF link. The buffer
contains the message Length and Data fields and a Buffer Full status flag, as
shown in Figure 18. The size of the buffer can be programmed by the user,
using the ROMEO_MAX_DATA_SIZE parameter in the Romeo.H header file.
You should make the buffer large enough to receive the largest message being
transferred. See ROMEO_MAX_DATA_SIZE on page 42 for details.
Note that storage for the ID and Checksum fields is not required. Each Romeo2
device has a fixed ID defined at compile time, so no additional storage is
required. The Romeo2 driver calculates the Checksum field for each message
internally, and compares it with the actual checksum received. If there is an
error, the driver status is updated to ROMEO_CHECKSUM_ERROR.
The application must not read from the receive buffer, nor read the Buffer Full
flag, before calling the RomeoStatus service to check if a new valid message
is waiting. To do so could result in reading a corrupted message (the driver may
store a new message in the buffer, while the application is reading the previous
message). After the application has successfully read the message, it must
clear the Buffer Full flag.
34 Software Drivers for Tango3 RF Transmitter and Romeo2 RF Receiver ICs MOTOROLA
For More Information On This Product,
Go to: www.freescale.com
Freescale Semiconductor, Inc.
AN2707
Romeo2 Driver
7 4 3 0
$xxxx BF Length
Data0
...
...
...
Data127
Freescale Semiconductor, Inc...
If a message is received and the receive buffer is full (BF flag = 1), the last
received message will be discarded and the driver status will be set to
ROMEO_OVERRUN.
After the driver has been initialized, it can be in one of five states (listed below).
Figure 20 shows the various states the driver will return, when the
RomeoStatus service is called.
Internal processing of the driver occurs when the main application calls any of
the run-time services, and after reception of data on the SPI interface. Since
reception of data is controlled by an SPI interrupt on the MCU, the user must
link the RomeoSPIRxInt service to the SPI interrupt. An example of this is given
in Adding the Romeo2 Driver to an Application on page 46.
MOTOROLA Software Drivers for Tango3 RF Transmitter and Romeo2 RF Receiver ICs 35
For More Information On This Product,
Go to: www.freescale.com
Freescale Semiconductor, Inc.
AN2707
Start
Call
RomeoInitialise
Freescale Semiconductor, Inc...
Call
RomeoEnable to enable
driver for reception
Call RomeoStatus
Driver status
=
ROMEO_MSG_READY ?
36 Software Drivers for Tango3 RF Transmitter and Romeo2 RF Receiver ICs MOTOROLA
For More Information On This Product,
Go to: www.freescale.com
Freescale Semiconductor, Inc.
AN2707
Romeo2 Driver
Call RomeoInitialise()
MUST DO THIS TO
INITIALISE DRIVER
Call ROMEO_DISABLED
RomeoDisable()
Call
Call
RomeoEnable()
RomeoDisable()
Call
Freescale Semiconductor, Inc...
RomeoDisable()
Buffer Full
flag cleared
ROMEO_NO_MSG
Buffer Full
flag cleared
Msg received with
checksum error Call
RomeoDisable()
Buffer Full
Msg received
flag cleared
ROMEO_OVERRUN
ROMEO_CHECKSUM_ERROR
ROMEO_MSG_READY
MOTOROLA Software Drivers for Tango3 RF Transmitter and Romeo2 RF Receiver ICs 37
For More Information On This Product,
Go to: www.freescale.com
Freescale Semiconductor, Inc.
AN2707
Romeo2 Driver This section provides descriptions of each service provided by the Romeo2
Services driver.
RomeoInitialise
RomeoEnable
38 Software Drivers for Tango3 RF Transmitter and Romeo2 RF Receiver ICs MOTOROLA
For More Information On This Product,
Go to: www.freescale.com
Freescale Semiconductor, Inc.
AN2707
Romeo2 Driver
RomeoDisable
RomeoStatus
MOTOROLA Software Drivers for Tango3 RF Transmitter and Romeo2 RF Receiver ICs 39
For More Information On This Product,
Go to: www.freescale.com
Freescale Semiconductor, Inc.
AN2707
RomeoStrobeHigh
RomeoStrobeLow
RomeoStrobeTriState
40 Software Drivers for Tango3 RF Transmitter and Romeo2 RF Receiver ICs MOTOROLA
For More Information On This Product,
Go to: www.freescale.com
Freescale Semiconductor, Inc.
AN2707
Romeo2 Driver
RomeoChangeConfig
RomeoSPIRxInt
Romeo2 Driver The Romeo2 driver has a static configuration at compile time. Its configuration
Configuration cannot be changed during run time. The driver configuration is defined in a
header file ‘Romeo.h’. Configuration options are available for:
• Message format
• Message data rate
• Message modulation format (OOK or FSK)
• Carrier frequency
• Strobe oscillator function
• MCU resources
MOTOROLA Software Drivers for Tango3 RF Transmitter and Romeo2 RF Receiver ICs 41
For More Information On This Product,
Go to: www.freescale.com
Freescale Semiconductor, Inc.
AN2707
When starting a new project using the Romeo2 driver, you should place files
‘Romeo.H’ and ‘Romeo.C’ in the project directory and a #include ‘Romeo.H’
statement in the main application file.
ROMEO_SPI_ADDRESS
Description: This defines the start address of the SPI control registers
in the MCU's memory map.
Values: Integer in range 0x0000–0xffff
Example:
#define ROMEO_SPI_ADDRESS 0x10 /* Address varies from MCU to MCU */
ROMEO_MAX_DATA_SIZE
Description: This defines the maximum number of data bytes that can
be transferred. This value is used to calculate the size of
the message receive buffer (receive buffer will be
ROMEO_MAX_DATA_SIZE + 1 byte.)
Values: Number in range 0–127
Example:
#define ROMEO_MAX_DATA_SIZE 8 /* Max size of data field = 8 bytes */
42 Software Drivers for Tango3 RF Transmitter and Romeo2 RF Receiver ICs MOTOROLA
For More Information On This Product,
Go to: www.freescale.com
Freescale Semiconductor, Inc.
AN2707
Romeo2 Driver
ROMEO_RESET
Description: This defines the I/O pin used to control Romeo2's RESET
pin.
Values: Any I/O pin configurable as an output can be used. Use
the naming convention specified in the CodeWarrior
header files.
Example:
#define ROMEO_RESET PTA_PTA0 /* Port A pin 0 used for RESET */
Freescale Semiconductor, Inc...
ROMEO_RESET_DDR
Description: This defines the data direction bit for the I/O pin used to
control Romeo2's RESET pin.
Values: Any I/O pin configurable as an output can be used. Use
the naming convention specified in the CodeWarrior
header files.
Example:
#define ROMEO_RESET_DDR PTA_PTA0 /* DDRA for Port A pin 0 */
ROMEO_MODE_VALUE
MOTOROLA Software Drivers for Tango3 RF Transmitter and Romeo2 RF Receiver ICs 43
For More Information On This Product,
Go to: www.freescale.com
Freescale Semiconductor, Inc.
AN2707
ROMEO_BAND_VALUE
ROMEO_SOE_VALUE
ROMEO_HE_VALUE
ROMEO_ID_VALUE
Description: This defines the ID word used for this particular Romeo2
IC.
Values: Integer in range 0 - 0xff that does not contain binary
sequence 0110
Example:
#define ROMEO_ID_VALUE 0x55 /* ID word set to 0x55 */
44 Software Drivers for Tango3 RF Transmitter and Romeo2 RF Receiver ICs MOTOROLA
For More Information On This Product,
Go to: www.freescale.com
Freescale Semiconductor, Inc.
AN2707
Romeo2 Driver
ROMEO_SPI_CLOCK_SPEED
ROMEO_SR_VALUE
Freescale Semiconductor, Inc...
Description: This defines the ratio SLEEP time over RUN time for the
strobe oscillator.
Values: 0 - strobe ratio = 3
1 - strobe ratio = 7
2 - strobe ratio = 15
3 - strobe ratio = 31
Example:
#define ROMEO_SR_VALUE 1 /* Sleep time is 7 x RUN time */
ROMEO_DR_VALUE
MOTOROLA Software Drivers for Tango3 RF Transmitter and Romeo2 RF Receiver ICs 45
For More Information On This Product,
Go to: www.freescale.com
Freescale Semiconductor, Inc.
AN2707
ROMEO_MG_VALUE
ROMEO_MS_VALUE
ROMEO_PG_VALUE
46 Software Drivers for Tango3 RF Transmitter and Romeo2 RF Receiver ICs MOTOROLA
For More Information On This Product,
Go to: www.freescale.com
Freescale Semiconductor, Inc.
AN2707
Adding the Romeo2 Driver to an Application
Figure 23 shows an example Romeo.H header file. This has been configured
for use with an MC68HC908GZ60 MCU Romeo2 is configured for 434 MHz
Freescale Semiconductor, Inc...
RomeoReceiveBuffer[] declaration
MOTOROLA Software Drivers for Tango3 RF Transmitter and Romeo2 RF Receiver ICs 47
For More Information On This Product,
Go to: www.freescale.com
Freescale Semiconductor, Inc.
AN2707
Freescale Semiconductor, Inc...
RomeoSPIRxInt entry
48 Software Drivers for Tango3 RF Transmitter and Romeo2 RF Receiver ICs MOTOROLA
For More Information On This Product,
Go to: www.freescale.com
Freescale Semiconductor, Inc.
AN2707
Adding the Romeo2 Driver to an Application
/*****************************************************************************************/
/* THIS SECTION CONTAINS VALUES YOU MUST DEFINE! */
/*****************************************************************************************/
#include <MC68HC908GZ60.h> /* include peripheral declarations */
/*****************************************************************************************/
/* These may be omitted depending on hardware setup */
/*****************************************************************************************/
#define ROMEO_STROBE PTG_PTG1 /* #defines for STROBE pin */
#define ROMEO_STROBE_DDR DDRG_DDRG1 /* If hardwired,delete #defines */
MOTOROLA Software Drivers for Tango3 RF Transmitter and Romeo2 RF Receiver ICs 49
For More Information On This Product,
Go to: www.freescale.com
Freescale Semiconductor, Inc.
AN2707
4. After a message has been read from the receive buffer, the Buffer Full
flag in the receive buffer (bit 8 in byte 0 of buffer) should be cleared to
indicate the receive buffer is now available for new messages.
Figure 24 shows a simple example using the Romeo2 driver that receives all
messages.
Figure 23 shows the contents of the Romeo.h file for this example.
50 Software Drivers for Tango3 RF Transmitter and Romeo2 RF Receiver ICs MOTOROLA
For More Information On This Product,
Go to: www.freescale.com
Freescale Semiconductor, Inc.
AN2707
Using the Romeo2 Driver in an Application
Freescale Semiconductor, Inc...
Trademarks • Motorola and the Motorola logo are registered trademarks of Motorola,
Inc.
• CodeWarrior® is a registered trademark of MetroWerks, a wholly owned
subsidiary of Motorola, Inc.
MOTOROLA Software Drivers for Tango3 RF Transmitter and Romeo2 RF Receiver ICs 51
For More Information On This Product,
Go to: www.freescale.com
Freescale Semiconductor, Inc.
JAPAN:
Motorola Japan Ltd.
SPS, Technical Information Center
3-20-1, Minami-Azabu
Minato-ku
Tokyo 106-8573, Japan
81-3-3440-3569 Information in this document is provided solely to enable system and software
implementers to use Motorola products. There are no express or implied copyright
ASIA/PACIFIC:
Motorola Semiconductors H.K. Ltd. licenses granted hereunder to design or fabricate any integrated circuits or
Freescale Semiconductor, Inc...
Silicon Harbour Centre integrated circuits based on the information in this document.
2 Dai King Street
Tai Po Industrial Estate Motorola reserves the right to make changes without further notice to any products
Tai Po, N.T. Hong Kong herein. Motorola makes no warranty, representation or guarantee regarding the
852-26668334
suitability of its products for any particular purpose, nor does Motorola assume any
HOME PAGE: liability arising out of the application or use of any product or circuit, and specifically
http://motorola.com/semiconductors disclaims any and all liability, including without limitation consequential or incidental
damages. “Typical” parameters which may be provided in Motorola 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.
Motorola does not convey any license under its patent rights nor the rights of
others. Motorola 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 Motorola product could create a situation where personal injury or
death may occur. Should Buyer purchase or use Motorola products for any such
unintended or unauthorized application, Buyer shall indemnify and hold Motorola
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 Motorola
was negligent regarding the design or manufacture of the part.
Motorola and the Stylized M Logo are registered in the U.S. Patent and Trademark
Office. digital dna is a trademark of Motorola, Inc. All other product or service
names are the property of their respective owners. Motorola, Inc. is an Equal
Opportunity/Affirmative Action Employer.
© Motorola, Inc. 2004
AN2707
For More Information On This Product,
Go to: www.freescale.com