151-0153 Rabbit Semiconductor, 151-0153 Datasheet - Page 79

no-image

151-0153

Manufacturer Part Number
151-0153
Description
ASSEMBLY - RABBITFLEX CABLES
Manufacturer
Rabbit Semiconductor
Series
RabbitFLEX™r
Datasheet

Specifications of 151-0153

Accessory Type
Cable Assembly
For Use With/related Products
BL300F
Lead Free Status / RoHS Status
Vendor undefined / Vendor undefined
6.4 Software Walk-Through
In this section, we will begin with the speaker_tone.c sample program and modify it to demonstrate
more RabbitFLEX functionality. Note that to make the modifications and run the sample program, you
will need the speaker option, appropriate digital inputs and outputs, and the demo board that is included
with the RabbitFLEX tool kit. However, even if you do not have these items, you should still be able to
read along to gain more understanding of how to use the RabbitFLEX software.
6.4.1 Studying speaker_tone.c
The speaker_tone.c sample program demonstrates how to use the tone driver. For the purposes of
RabbitFLEX, it is not necessary to understand all of the details of this sample program, but essentially it
builds waveforms at different frequencies to be used with the tone driver. The refwave_organ() and
refwave_saw() functions build the waveforms; the buildwave() function adapts the organ and
saw waveforms to different frequencies.
In the following walk-through, we will only be making changes to the main() function, so it is probably
worth studying main() to understand it.
The above section of code simply declares some variables for later use in main().
The brdInit() function must be called at the beginning of every RabbitFLEX BL300F program. It sets
up internal data structures, initializes analog capabilities, sets up CPU registers appropriately, etc. If this
function is not called, then much of the RabbitFLEX I/O capability will be unavailable.
The above function is used to set the PWM (Pulse Width Modulation) channel that the speaker uses. This
introduces the idea of using data structures to pass information into the RabbitFLEX functions.
MY_SPEAKER is a macro that has been defined at the top of the program to flex_speaker. So, with-
out the macro definition, this line would be:
flex_speaker is a data structure of type Flex_IOPin. These data structures contain all of the infor-
mation that the RabbitFLEX functions need to know about the given pin. In this case, the structure con-
tains the correct PWM channel. Note that instead of passing the data structure itself, we pass a pointer to
the data structure. We will see this again and again in other RabbitFLEX functions.
RabbitFLEX User’s Manual
void main(void)
{
flexSpeakerPWM(&flex_speaker);
char ch;
char repeat;
int request_exit;
// This function must be called to initialize the RabbitFLEX board
brdInit();
// This function sets the correct PWM channel to use for the speaker.
// Simply pass a pointer to the speaker structure.
flexSpeakerPWM(&MY_SPEAKER);
// Holds the user command
// Indicates whether or not the tone should repeat
// Indicates if user has requested to exit the program
www.rabbit.com
73

Related parts for 151-0153