DOC PREVIEW
Berkeley ELENG 290Q - Energy Consumption, Wireless Chat

This preview shows page 1-2-3 out of 9 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 9 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 9 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 9 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 9 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Lab 2: Energy Consumption, Wireless ChatUC Berkeley - EE 290QThomas WatteyneJanuary 25, 20101 Using the Texas Instruments DriversTexas Instruments has developed a set of drivers for the eZ430-RF2500 as partof the simpliciTI project, freely available online1. We will assume that thesedrivers are copied in sourcecode/drivers/.Follow these steps when you are asked to create a new project:• In IAR, create the new project as instructed in Lab 1.• Go to Project > Options (Alt+F7), then to C/C++ compiler. In thePreprocessor tab, add the following lines in the Additional includedirectories text field. This tells IAR to look into these folders whenyou include files in your source code.$PROJ_DIR$\..\drivers\bsp$PROJ_DIR$\..\drivers\bsp\drivers$PROJ_DIR$\..\drivers\bsp\boards\EZ430RF$PROJ_DIR$\..\drivers\mrfi• In the Defined symbols text field, add the following line. This tells thedrivers you have a CC2500 radio chip on your board.MRFI_CC2500• in the Workspace panel, right click on the name of your project, and useAdd > Add Group... to make the following group structure:- Application- Components- bsp- mrfi- Output• use Add > Add Files... to add files bsp.c, bsp.h and bspmacros.hunder group bsp. Similarly, add files mrfi.c, mrfi.h and mrfi defs.hunder group mrfi. Add your C code as a file under group Application1Also at http://www.eecs.berkeley.edu/∼watteyne/290Q/labs/drivers.zip12 txrx simple: Simple Tx/RxGoal. This first example involves two boards which stay in Rx mode bydefault. When you press a button on either one, it sends a message andtoggles its red LED; the board which receives the message toggles its greenLED. Once this is functional, you will play with the Rx/Tx frequency.2.1 Running the Code• create a new project called txrxsimple;• in IAR, copy the code presented in Listing 1 (p.3).• compile and download the code onto both boards (Ctrl+D);• switch both boards on (one with the battery unit, the other with the USBslot of your PC); when you press one’s button, the other’s red L ED shouldtoggle.The packet format is shown in Table 1 (p.3). A variable of type mrfiPackettis a structure containing two parts:• packet.frame is the frame to be transmitted. The first byte is the Lengthof the payload together with source and destination Address. With thecurrent driver implementation, addresses are coded on 4 bytes, and themaximum Payload length is 20 bytes. By default, the CC2500 does notperform address filtering, so in practice we will not care about the valuesof the address fields.• packet.rxMetrics are statistics on the last received packet, i.e. it onlymakes sense on received packet. The first byte is the Received SignalStrength Indicator (RSSI) at sync word detection. This is the signal levelin dBm. The next bit indicates whether the Cyclic Redundancy Check(CRC) was successful (by default, the CC2500 is configured to reject pack-ets with an unsuccessful CRC check, so in practice this field will alwaysbe 1). The last 7 bits are the Link Quality Indicator (LQI). The LQI givesan estimate of how easily a received signal can be demodulated by accu-mulating the magnitude of the error between ideal constellations and thereceived signal over the 64 s ymbols 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 todefinition of "BSPInit()" if you want to know) which disables thewatchdog, initializes the MCLK at 8MHz, sets LED ports as outputs andthe button port as input. Note that it does neither enables the internalresistor of the button, nor enables interrupts. This is done on lines 5 and6.2Listing 1: The simplest Tx/Rx example possible (Section 2).1 #i n cl u d e ” m r f i . h”2 i n t main ( void )3 {4 BSPInit ( ) ;5 P1REN |= 0x04 ;6 P1IE |= 0 x04 ;7 MRFIInit ( ) ;8 MRFIWakeUp ( ) ;9 MRFI RxOn ( ) ;10 b i s S R r e g i s t e r (GIE+LPM4 bits ) ;11 }12 vo id MRFIRxCompleteISR ( )13 {14 P1OUT ˆ= 0 x02 ;15 }16 #pragma ve ct o r=PORT1VECTOR17 i n t e r r u p t voi d Port 1 ( void )18 {19 P1IFG &= ˜0 x04 ;20 m r f iP a c ke tt pac ket ;21 pa ck et . frame [0]=8+20;22 MRFITransmit(&packet , MRFI TX TYPE FORCED ) ;23 P1OUT ˆ= 0 x01 ;24 }0 8 16 24 32 40LengthSourceDestinationPayload(Length-8 bytes long)packet.frame0 8 16RSSICRCLQIpacket.rxMetricsTable 1: Packet format.3• Line 7. MRFI stands for Minimal Radio-Frequency Interface; functionsstarting with MRFI are used to drive the CC2500 radio chip. MRFI Init()initializes the 6 wires between the MSP430 and the CC2500, powers-up theCC2500 and configures the CC2500 47 registers and turns on interruptsfrom the CC2500;• Line 8 wakes up the radio, i.e. it turns on the 26MHz crystal attach toit without entering Rx or Tx mode;• Line 9 switches the radio to Rx mode; from this line on, it can receivepackets, in which case the interrupt function MRFIRxCompleteISR2iscalled.2.2 Choosing a FrequencyThe CC2500 can transmit at any frequency on the ISM band 2400.0-2483.5MHz.The chip divides the 2400.0-2483.5 MHz spectrum into channels separated by atunable channel spacing. By default, channel spacing is 200kHz; with defaultconfiguration, channel 0 is 2433.0Mhz, channel 1 is 2433.2Mhz, and so forth.The channel is configured through the CHANNR register.In a lab environment, as you don’t want to interfere with other groups,each group needs to pick a different channel. To avoid co-channel interference(a channel may ”leak” into its neighboring channels, leading to interference),space frequencies as much as possible.• add after line 1 the following line. This way, you have access to low leveldriver functions which enable you to write directly the CC2500 registers:#include "radios/family1/mrfi_spi.h"• add after line 7 the following line, replacing 0x10 by the frequency you havechosen. This programs the CHANNR register of the CC2500. Be aware thatvalues above 0xFC are prohibited because the corresponding frequency isabove 2483.5 MHz:mrfiSpiWriteReg(CHANNR,0x10);When you have reprogrammed both boards, you should be able to commu-nicate without interference.You will need to add these lines for all subsequent exercises to isolate youfrom interference from other groups.2Note that the real interrupt function with the usual pragma declaration is contained inthe drivers41.240ms0.280ms0.800ms25.2mA11.4mA5.20mA(a) Transmitter1.24ms0.360ms0.740ms22.5mA19.5mA17.1mA(b) ReceiverFigure 1: Energy consumption with continuous Tx/Rx.3 Continuous


View Full Document

Berkeley ELENG 290Q - Energy Consumption, Wireless Chat

Documents in this Course
Lab 1

Lab 1

16 pages

Lab 1

Lab 1

16 pages

Load more
Download Energy Consumption, Wireless Chat
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Energy Consumption, Wireless Chat and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Energy Consumption, Wireless Chat 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?