Design of wireless data transmission system based on MSP430 and nRF905

Design of wireless data transmission system based on MSP430 and nRF905
2006-09-24 21:05 Application of single chip microcomputer and embedded system

In data measurement and control applications in special environments, wireless data transmission has been more and more widely used. The combination of MSP430 + nRF905 is particularly suitable for low-power, short-distance (100-200m), small data volume wireless data transmission systems. MSP430 CPU has great advantages in low-power applications. The nRF905 wireless transceiver chip has the advantages of low power consumption, simple control, automatic processing of headers and CRC check. The combination of the two can be used in many products. Get applied.
1 Introduction to MSP430

MSP430 is a new 16-bit series microcontroller from TI. It has unique advantages in battery-powered low-power applications. Its operating voltage is between 1.8-3.6V, and power consumption can be controlled at about 200μA during normal operation. The consumption mode makes it possible to achieve low power consumption of 2μA or even 0.1μA. The MSP430 has a very high degree of integration. Usually, a 12-bit A / D, comparator, multiple timers, on-chip USART, and watchdog are integrated on a single chip. Dogs, on-chip oscillators, a large number of I / O ports, and large-capacity on-chip memories, generally a single chip can meet most application needs.

When designing programs in low-power applications, it is best to use the following methods: After the initialization is complete, the CPU is in low-power operation mode, wake up to enter the terminal service program when an external event occurs, and re-enter low-power mode after completion. In this way, the power consumption can be reduced to the greatest extent.

2 Introduction to nRF905

nRF905 is a monolithic RF transmitter chip launched by Nordic in Norway. The operating voltage is 1.9-3.6V, 32-pin QFN package (5mm × 5mm), and it works on three ISM channels of 433/868 / 915MHz (can be used for free). nRF905 can automatically complete the work of the header and CRT (Cyclic Redundancy Code Check), and can automatically complete Manchester encoding / decoding by on-chip hardware. It uses SPI interface to communicate with the microcontroller, the configuration is very convenient, and its power consumption is very low. When transmitting at an output power of -10dBm, the current is only 11mA, and in the receiving mode the current is 12.5mA.

The nRF905 transmits data in a non-real-time manner, that is, the sender sends out the data, and the receiver temporarily stores it in the chip memory after receiving it. The external MCU can go to the chip when needed. The maximum data transmission volume of nRF905 is 32B at a time.

2.1 The working mode and setting of nRF905

The two working modes and two energy-saving modes of nRF905 are power-down mode, standby mode, ShockBurst TM receiving mode and ShockBurst TM transmitting mode. These modes are controlled by the external CPU through the three pins nWR905 of PWR_UP, TRX_CE and The high and low levels of TX_EN are determined, as listed in Table 1.



The external MCU configures the internal register of nRF905 through the SPI bus. It must be set to standby or power-down mode when reading and writing data. The power consumption of nRF905 is 40μA in standby mode and 2.5μA in power-down mode.

2.2 Status output of nRF905

nRF905 has 3 pins for status output, namely: CD (Carrier Detect), AM (Address Match) and DR (Data Ready), which are all high-level active. When nRF905 is in the receive mode, if it detects the reception Carrier in the frequency band, set CD high, then detect the address byte in the carrier data, if it is the same as the configured receive address, then set AM high, if it is detected that the CRC check in the received data is correct, Then store valid data bytes and set DR high.

In addition, nRF905 has a clock output pin uPCLH for users to choose to use. By configuring the internal register, its frequency output can be changed, which is useful during debugging. The wireless system needs at least two devices for one transmission and one reception. It is difficult to determine which side is faulty if there is a problem during debugging. You can judge the hardware circuit and CPU operation by modifying the register of nRF905 and oscilloscope to observe whether the uPCLK output changes. The procedure of nRF905 is correct, so as to judge whether the device is working properly.

2.3 Data interface of nRF905

The peripheral MCU configures the internal registers of nRF905 and sends and receives data through the SPI bus. The SPI bus of nRF905 includes 4 pins: CSN (SPI enable), SCK (SPI clock), MISO (master input slave output) and MOSI (master output slave Into). Here nRF905 is a slave, its SPI clock range is very wide, can be from 1Hz-10MHz, so MCU does not have to demand time accuracy when writing control programs.

Each operation of the SPI bus must start on the falling edge of the enable pin CSN. CSN is active low. The data on the bus is valid at the rising edge of the clock. The MCU operates the SPI bus in two ways: reading And write, in the read operation, first set CSN low, and then output a byte representing the read command on the MOSI data line, at the same time, nRF905 will output a byte representing the status information on the MISO data line Then, an address byte is output, followed by valid data. The write operation is relatively simple. The MCU first pulls the CSN low, and then outputs the write command byte and data byte on the MOSI line.

2.4 Register configuration of nRF905

There are 5 types of registers in the nRF905: one is the radio frequency configuration register, a total of 10 bytes, including the central frequency point, wireless transmission power configuration, receiving sensitivity, the number of effective bytes of data sent and received, association address configuration and other important information; the second is the transmission The data register has a total of 32 bytes. The data to be sent out by the MCU needs to be written here. The third is the sending address, a total of 4 bytes. For a pair of transceiver devices to communicate normally, the sending address of the sending end and the receiving end need to be taken over. The address configuration is the same. The fourth is the receive data register, a total of 32 bytes. The valid data received by nRF905 is stored in these registers. The MCU can read it when needed. The fifth is the status register, 1 byte, containing the address Matching and data-ready information is generally not needed.

To operate these registers, the MCU must follow the operation commands specified in nRF905. The following 7 types are commonly used, all of which are 1 byte; write RF configuration (0XH, "X" contains 4 binary bits, this byte means to start The initial number of bytes written), read radio frequency configuration (1XH, "X" contains 4 binary bits, this byte indicates from which byte to start reading), write send data (20H), read send data (21H), Write send address (22H), read send address (23H) and read receive data (24H). For detailed information about registers, please refer to nRF905 data sheet.



2.5 The working process of nRF905

Before nRF905 works normally, the MCU should first write the configuration register according to the needs, or work according to the default configuration. The subsequent work is mainly two: sending data and receiving data.

When sending data, the MCU should first put nRF905 in standby mode (PWR_UP pin is high, TRX_CE pin is low), then write the sending address and the data to be sent to the corresponding register through the SPI bus, and then set nRF905 In the sending module (PWR_UP, TRX_CE and TX_EN are all set to high), the data will be automatically sent out through the antenna. If the automatic retransmission bit (AUTO_RETRAN) in the RF configuration register is set to yes, the data packet will be repeatedly sent out continuously Until the MCU pulls TRX_CE low and exits the send mode. In order to transmit data more reliably, it is recommended to use this method.

When receiving data, the MCU first writes the receiving address in the RF configuration register in the standby mode of nRF905, and then sets it in the receiving mode (PWR_UP = 1, TRX_CE = 1, TX_EN = 0), nRF905 will automatically receive the air Carrier, if the valid data with the address matching and correct verification is received, the DR pin will be set high automatically. After detecting this signal, the MCU can change to standby mode and read the valid data from the received data register through the SPI bus data.

3 System hardware design

The USART module of MSP430 can be configured as a universal asynchronous serial port or SPI module function through a register. Here it is configured as an SPI module. The MCU selected for this system is MSP430F133. During hardware design, connect the SPI interface of the MCU to the nRF9051SPI interface. In addition, Then select several I / O ports to connect Nrf9051 to output the output signal, as shown in Figure 1.



For the designer who is in contact with the wireless system for the first time, because of the procurement of components in the RF part, welding and debugging are more troublesome, you can choose the PTR8000 module. The core of the module uses nRF905. The hardware circuit has been soldered. It is relatively convenient in October.

4 Control programming

The focus of this system design is to control the programming of the nRF901, which is roughly divided into two stages: first, the initial configuration of the NrF905, and after the configuration is complete, the portable secretary's sending or receiving program is required.

4.1 Initial configuration

The first stage should complete the initial configuration, divided into the following items:

1) SPI interface setting of MSP430, MSP4301 asynchronous serial interface and SPI interface use the same USART module, software needs to be configured as SPI function in this thief, in this design SPI configuration is a host module, 3-wire system and 8-bit data, program For the source code, see the subroutine "SPI_SET 5". (Editor's Note: The source code of the program can be found on our website)

2) Initialize the RF configuration registers of nRF901. There are a lot of information in these registers, which must be configured according to the actual situation. In this design, nRF905 external 16MHz crystal, "XOF should be configured to" 011 ";" PA_PWR "is the transmit power, RX_RED_PWR" is Receiving life sensitivity can be configured as needed; in addition, the length (number of bytes) of the sending address, receiving address, sending data and association data can be configured according to the actual application, pay attention to the actual address when receiving CNOOC in the thief group register, instead of sending The address is in a separate register.

3) Prepare the sending address of nRF901, up to 4 bytes (32 bits). The sending address of the sending end should be the same as the association address of the receiving device. In actual work, nRF901 can automatically filter out the data with different addresses, only the address The matched and verified data painting is accepted and stored in the received data register.

4.2 Sending data

Before enabling nRF905 to send data, MSP430 needs to fill the transmit data register in standby mode via the SPI bus in standby mode, at most 32B at a time, but nRF9051 "TRX_CE", "TX_EN" should be set to high level, the data It will be automatically sent out, the automatic retransmission bit is selected in the RF configuration register of this design, so the data has been sent repeatedly and repeatedly during the time that "TRX_CE" is set high. In this program, the delay is designed to be 500ms, and then "TR X_CE" is pulled down, so it returns to the standby mode.

4.3 Receive data

MSP430 sets the "TRX_CE" pin of nRF905 to high level, and etches the association data after the "TX_CE pin is pulled to low level. In this design, the CPU always judges whether the Nrf9051" DR "pin is within 35s. It becomes taller, if it is high, it means that it has received valid data, and it can exit the receiving mode. Weak consistency does not accept 2 to. When the time is up, it also exits to accept the acceptance module. After exiting, it is in the standby module. The CPU puts NRF905 through the SPI bus The data in the internal receive data register is read out, that is, moral and valid data is received.

When accepting some programs portablely, it should be noted that there is no mention in many materials, that is, after the CPU sends a read command byte on the MOSI signal line, the nRF905 on the "MISO" signal line will automatically return one byte of data. Status register information, subsequent received data will not automatically follow the output, only the CPU outputs a byte on MOSI (can be any value), nRF905 will return a byte on "MISO", the CPU sends again, nRF905 then Full meeting until finished reading.


It can be equipped with different type of storage battery such as lead acid battery, Nickel Cadmium Battery, silver zinc battery, Lithium Ion Battery and other storage batteries, providing various output voltage classes.

Built-in storage battery and charger, equipped with the function of over-charge and over-discharge protection and capacity display. It is used as working power supply for lightings, communications, laptops, and special instruments of emergency working, field working, press interviews, special vehicles and other fields.


DC Power Supply

Dc Power Supply,110V Dc Power Supply,220V Dc Power Supply,110V Dc Power Supply System

Xinxiang Taihang Jiaxin Electric Tech Co., Ltd , https://www.chargers.be