<< Chapter < Page Chapter >> Page >
This first example involves two boards which stay in Rx mode by default. When you press a button on either one, it sends amessage and toggles its green LED; the board which receives the message toggles its red LED. Once this is functional, youwill play with the Rx/Tx frequency.

Running the code

  • Copy the code presented below Alternatively, this code is available in the downloadable source code . Open source_code/iar_v4.11/lab_ezwsn.eww with IAR. The project corresponding to this section is called txrx_simple . .
  • Compile and download the code onto both boards (Ctrl+D) .
  • Switch both boards on (one with the battery unit, the other with the USB slot of your PC); when you press one's button, the other's red LED should toggle.
#include "mrfi.h" #include "radios/family1/mrfi_spi.h"int main(void) {BSP_Init(); P1REN |= 0x04;P1IE |= 0x04; MRFI_Init();MRFI_WakeUp(); MRFI_RxOn();__bis_SR_register(GIE+LPM4_bits); }void MRFI_RxCompleteISR() {P1OUT ^= 0x02; }#pragma vector=PORT1_VECTOR __interrupt void Port_1 (void){ P1IFG&= ~0x04; mrfiPacket_t packet;packet.frame[0]=8+20;MRFI_Transmit(&packet, MRFI_TX_TYPE_FORCED); P1OUT ^= 0x01;}
The simplest Tx/Rx example possible

The packet format is:

packet.frame
Length (1B) Source (4B) Destination (4B) Payload (Length-8 bytes long)
packet.rxMetrics
RSSI (1B) CRC (1b) LQI (1b)

A variable of type mrfiPacket_t is a structure containing two parts:

  • packet.frame is the frame to be transmitted. The first byte is the Length of the payload together with source and destination Address. With the current driver implementation, addresses are coded on 4 bytes, and the maximumPayload length is 20 bytes. By default, the CC2500 does not perform address filtering, so in practice we will not care about the values of the address fields.
  • packet.rxMetrics are statistics on the last received packet, i.e. it only makes sense on received packet. The first byte is the Received Signal StrengthIndicator ( RSSI ) at sync word detection. This is the signal level in dBm. The next bit indicates whether the Cyclic Redundancy Check ( CRC ) was successful (by default, the CC2500 is configured to reject packets with unsuccessful CRCcheck, so in practice this field will always be 1). The last 7 bits are the Link Quality Indicator ( LQI ). The LQI gives an estimate of how easily a received signal can be demodulated by accumulating the magnitude of the error between idealconstellations and the received signal over the 64 symbols immediately following the sync word.

Some keys for understanding the code:

  • Line 4 is a function from the drivers (right-click on it, and choose Go to definition of "BSP_Init()" if you want to know) which disables the watchdog, initializes the MCLK at 8MHz, sets LED ports as outputs and thebutton port as input. Note that it does neither enables the internal resistor of the button, nor enables interrupts. This is done on lines 5 and 6.
  • Line 7. MRFI stands for Minimal Radio-Frequency Interface; functions starting with MRFI are used to drive the CC2500 radio chip. MRFI_Init() initializes the 6 wires between the MSP430 and the CC2500, powers-up the CC2500 and configures the CC2500 47 registers and turns on interrupts from the CC2500;
  • Line 8 wakes up the radio, i.e. it turns on the 26MHz crystal attach to it without entering Rx or Tx mode;
  • Line 9 switches the radio to Rx mode; from this line on, it can receive packets, in which case the interrupt function MRFI_RxCompleteISR is called Note that the real interrupt function with the usual #pragma declaration is hidden in the drivers .

Choosing a frequency

The CC2500 can transmit at any frequency on the ISM band 2400.0-2483.5 MHz . The chip divides the 2400.0-2483.5 MHz spectrum into channels separated by a tunable channel spacing . By default, channel spacing is 200kHz; with default configuration, channel 0 is 2433.0Mhz, channel 1 is 2433.2Mhz, and so forth. Thechannel is configured through the CHANNR register of the CC2500.

  • add 1 the following line at the very top of the code. This way, you have access to low level driver functions which enable you to write directly the CC2500 registers: #include "radios/family1/mrfi_spi.h"
  • add the following line right after MRFI_Init(); . You may replace 0x10 by the frequency you have chosen. This programs the CHANNR register of the CC2500. Be aware that values above 0xFC are prohibited because the corresponding frequency is above 2483.5 MHz: mrfiSpiWriteReg(CHANNR,0x10);

When you have reprogrammed both boards, you should be able to communicatewithout interference.

Questions & Answers

what is microbiology
Agebe Reply
What is a cell
Odelana Reply
what is cell
Mohammed
how does Neisseria cause meningitis
Nyibol Reply
what is microbiologist
Muhammad Reply
what is errata
Muhammad
is the branch of biology that deals with the study of microorganisms.
Ntefuni Reply
What is microbiology
Mercy Reply
studies of microbes
Louisiaste
when we takee the specimen which lumbar,spin,
Ziyad Reply
How bacteria create energy to survive?
Muhamad Reply
Bacteria doesn't produce energy they are dependent upon their substrate in case of lack of nutrients they are able to make spores which helps them to sustain in harsh environments
_Adnan
But not all bacteria make spores, l mean Eukaryotic cells have Mitochondria which acts as powerhouse for them, since bacteria don't have it, what is the substitution for it?
Muhamad
they make spores
Louisiaste
what is sporadic nd endemic, epidemic
Aminu Reply
the significance of food webs for disease transmission
Abreham
food webs brings about an infection as an individual depends on number of diseased foods or carriers dully.
Mark
explain assimilatory nitrate reduction
Esinniobiwa Reply
Assimilatory nitrate reduction is a process that occurs in some microorganisms, such as bacteria and archaea, in which nitrate (NO3-) is reduced to nitrite (NO2-), and then further reduced to ammonia (NH3).
Elkana
This process is called assimilatory nitrate reduction because the nitrogen that is produced is incorporated in the cells of microorganisms where it can be used in the synthesis of amino acids and other nitrogen products
Elkana
Examples of thermophilic organisms
Shu Reply
Give Examples of thermophilic organisms
Shu
advantages of normal Flora to the host
Micheal Reply
Prevent foreign microbes to the host
Abubakar
they provide healthier benefits to their hosts
ayesha
They are friends to host only when Host immune system is strong and become enemies when the host immune system is weakened . very bad relationship!
Mark
what is cell
faisal Reply
cell is the smallest unit of life
Fauziya
cell is the smallest unit of life
Akanni
ok
Innocent
cell is the structural and functional unit of life
Hasan
is the fundamental units of Life
Musa
what are emergency diseases
Micheal Reply
There are nothing like emergency disease but there are some common medical emergency which can occur simultaneously like Bleeding,heart attack,Breathing difficulties,severe pain heart stock.Hope you will get my point .Have a nice day ❣️
_Adnan
define infection ,prevention and control
Innocent
I think infection prevention and control is the avoidance of all things we do that gives out break of infections and promotion of health practices that promote life
Lubega
Heyy Lubega hussein where are u from?
_Adnan
en français
Adama
which site have a normal flora
ESTHER Reply
Many sites of the body have it Skin Nasal cavity Oral cavity Gastro intestinal tract
Safaa
skin
Asiina
skin,Oral,Nasal,GIt
Sadik
How can Commensal can Bacteria change into pathogen?
Sadik
How can Commensal Bacteria change into pathogen?
Sadik
all
Tesfaye
by fussion
Asiina
what are the advantages of normal Flora to the host
Micheal
what are the ways of control and prevention of nosocomial infection in the hospital
Micheal
Got questions? Join the online conversation and get instant answers!
Jobilize.com Reply

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Ezwsn: experimenting with wireless sensor networks using the ez430-rf2500. OpenStax CNX. Apr 26, 2009 Download for free at http://cnx.org/content/col10684/1.10
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Ezwsn: experimenting with wireless sensor networks using the ez430-rf2500' conversation and receive update notifications?

Ask