PIC32MX: High-speed Wireless Communication
Revision as of 12:04, 15 February 2010
Do not erase this section!
Your assignment is to create the circuit and code that allows two PIC32s to use wireless communication at high speeds using the Transceiver nRF24L01+ Module with Chip Antenna from Sparkfun.
Read up on the nRF24L01+ Module commands and create functions to allow a PIC32 to initialize and send and receive data.
Test your code by sending 1000 bytes of data from one PIC32 to the other and echo the data back. How long does this transmission take? How far can you separate the PIC32s before the transmission is unreliable?
The goal of this project is to transmit a byte of data (e.g. a character) from one PIC32/nRF24L01+ board to the other board, and display the received character on a PC screen.
This wiki describes how to wire a nRF24L01+ chip ("wireless chip") to the transmitting PIC32 board ("transmitter") and receiving PIC32 board ("receiver"), and includes annotated code describing the functions that facilitate the wireless communication.
The wireless chip has 8 pins that need to be wired to the PIC:
(1) Vcc -> +3.3 Vdc supply
(2) CE -> uC pin PORTC.1, configured as GPIO/input
(3) CSN -> uC pin PORTC.2, configured as GPIO/output
(4) SCK -> uC pin PORTC.3/SCK, configured as SCK(SPI)/output
(5) MOSI -> uC pin PORTC.5/SDO, configured as SDO(SPI)/output
(6) MISO -> uC pin PORTC.4/SDI, configured as SDI(SPI)/input
(7) IRQ -> uC pin PORTB.0, configured as GPIO/input
(8) GND -> common digital ground
The +3.3V and ground are provided by the NU32 board. The term "uC" above stands for microcontroller, which is the PIC32 in our case. GPIO stands for General Purpose Input/Output.
Descriptions of the wireless chip's pins can be found in Brennan Ball's DIYembedded Tutorial 0. The SCK, MOSI, and MISO pins interface with the SPI on the PIC32 which allows for communication between the PIC and the wireless chip. The GPIO pins will be initialized as digital inputs or outputs in the code to enable/disable the wireless chip and check the wireless data transfer/receive stats.
In order to print information from the PIC to the PC, we need to wire an PIC_RS232 cable's transfer and receive lines to the UART ports of the NU32 board (F4, F5).
Where possible, make it a single piece of well-commented cut-and-pastable code, or at least make each function that way, so others can easily copy it. Most comments should be in the code itself; outside the code (on the wiki) should only be explanatory comments that are too cumbersome to include in the code.