Before you delve too far into this, some background reading will be helpful. Essentially SPI is two shift registers (one in and one out). Here is some general info on shift registers: http://en.wikipedia.org/wiki/Shift_register. There is also an article on SPI, but it’s not as useful: http://en.wikipedia.org/wiki/Serial_Per … _Interface. Take a look at the nRF24L01 datasheet on page 20 to see the intricacies of the SPI interface for the 24L01. It will help illustrate some of the questions I’m answering.
For CSN, what is it used to select between? Is it used to switch between regular data transmission mode and configuration mode?
If a device's chip select is high, its SPI interface assumes that it is not being used. This is to allow multiple devices to be used on a bus (each device must have its own CSN that is independent of every other device's CSN). When the CSN goes low, the device will expect an SPI receive. Once the CSN goes back high, the device will process whatever it received on the SPI interface.
You said SCK is the clock for the SPI interface. Could you explain this a little more? I don’t really understand “clocking data bits”. Could you please explain this? Thanks.
When the SPI interface on a device is active (i.e., CSN is low for the nRF24L01), it samples its data pin (the nRF24L01 will sample the MOSI pin) on a specified clock edge, either rising or falling (the nRF24L01 uses a falling clock edge to sample data). To illustrate the point, assume CSN is low, which indicates to the 24L01 it is receiving SPI data. Then, every time SCK goes from high to low, the 24L01 will shift in whatever it reads on the MOSI pin. It will continue to do this until CSN goes back high. This is illustrated on page 20 of the datasheet.
You said VDD_PA is the power amplifier. If I remember correctly, the datasheet showed this hooked up to 1.8v. How can it amplify power when it has a lower voltage than VCC? What does this pin do then? If you adjust the amount voltage to this pin, will it change the power of the transmitting?
More than likely there is some level transition within the chip itself. You don't change the voltage on this pin to change the power. There is a configuration register that allows you to change it (RF_SETUP register, RF_PWR field...see the datasheet on page 23).
For the antenna outputs, you said you need a matching network for a regular antenna. What kind of “matching network” do you need?
It is illustrated on page 33 of the datasheet, but on the MiRF boards, it is already done for you. You only have to worry about the pins I described in my last post. On page 33, it is basically all the stuff hooked up to the pins ANT1, ANT2, and VDD_PA.
So DVDD’s only purpose is connect a decoupling capacitor to ground? The purpose of a decoupling capacitor is to prevent sudden voltage changes, right?
It has several purposes. Its main purpose is to shunt AC frequencies to ground so that the internal DVDD is as purely DC as possible (capacitor impedance is infinity at DC and decreases as frequency increases). It does help to stabilize the power supply against sudden inrush currents that could cause the supply voltage to temporarily drop if the capacitor wasn't there.
Let’s say you want to send a number from 0 to 255. Let’s pick 255. How many bytes would this be? Anyway, let’s say we are going to send this number to the receiver. The first thing you do would be to send the write data instruction. How do you do this? Is this the preamble? What pin do you send it to, and what kind of instruction is it? Next you clock the data bits. How is this done? What about the address data in the packet? Where does that come in?
This would require one byte. Since there are 8 bits in a byte, one byte can go from 0 to 2^8-1, or 255. If you want to know what the capacity of any data word is (8 bits, 16 bits, 32 bits, etc.), just raise 2 to the power of the number of bits in the word. The maximum number that this word can hold is one less than that (since it also has to hold 0). Learn about binary here: [http://en.wikipedia.org/wiki/Binary_numeral_system](http://en.wikipedia.org/wiki/Binary_numeral_system).
First off, turn to page 19 of the datasheet. You will want to use the W_TX_PAYLOAD instruction. Therefore, you will first bring CSN low, and then send the binary number ‘10100000’ or 0xA0 in hex (http://en.wikipedia.org/wiki/Hexadecimal) over the SPI interface. This tells the 24L01 that it will be receiving a data payload. Once the instruction is sent, you immediately (without bringing CSN high) send all of your payload bytes. Then you bring CSN back high again. The only issue here is that the 24L01 will be expecting a certain number of bytes in the payload. This is specified in RX_PW registers and can be different for each data pipe.
The 24L01 will handle the preamble, address bits, and CRC for you. You simply have set up the configuration for each of them in the configuration registers. This is what Shockburst mode is - it simplifies all the details so that you just have to send a command (here the write payload instruction) and data to go with that command (here your data payload, or the 0 to 255 number).
On this receiving end. When the data is received, IRQ will go HIGH (LOW?). The microcontroller on that end will read IRQ, and send the instruction to read data. Again, how do you send this instruction? Next you clock out the data bits. I’m sure this is similar to clocking in data bits, but how is this done? After that the microcontroller can do whatever it needs. When data is received and “clocked out” by the micro, what part of the packet will the micro get? Will it get the preamble and the address data, or just the data (in this case the number 255) I want it to get?
On page 10 of the datasheet, it shows that IRQ is active low (which means it will be ground when active). The receiving process is pretty much identical to the writing process, and the main difference is that you send the R_RX_PAYLOAD instruction instead of the W_TX_PAYLOAD instruction. What comes out is the data payload, meaning that the 24L01 has stripped away the preamble, address, and CRC from the message it received. That way, you only get data that is useful to you and don't have to process other stuff.
You generally want to tie IRQ to a pin on your microcontroller that can act as an interrupt. This will free you from constantly having to poll the IRQ pin in the microcontroller to see if it has received data. This setup will also generally allow for better data throughput if your micro is doing a lot of other stuff besides simply reading from the data pin.
Wow, that was probably the longest post I’ve ever made :lol: . I hope I answered your questions as well as I can, and if you have any more feel free to ask. I would highly suggest you look at some of the background reading that I have linked to before you continue with your project. Also, most of the information that you asked about is in the datasheet, so once you get the background stuff you should be able to better understand the datasheet information. You will find that google, wikipedia, and datasheets are your best friend when it comes to this stuff (though datasheets in particular can also be your biggest foe when they’re incorrect :evil: ).