I have not programmed a Pic in C at this point so I need a bit of help. In the Pic example on http://www.sparkfun.com/commerce/produc … cts_id=691 at several points it has a word then a .#, like cmd.7, data.7, OSCCON.2 . What is the purpose?
You need to read the documentation for the C compiler they used, it is very non-standard. They denote bits.
I’ve got some similar test code here that uses the Microchip C18 compiler:
http://www.leonheller.com/MiRF%20V2/
Leon
I am also releasing an assembly version of the nRF24L01+ library this week with full examples of working it with output to LEDs and to USART if you prefer assembly.
As for the .7 .6 etc… they are just referring to the bit number of the byte variable, so OSCCON in C is referring to the OSCCON register in assembly, and .2 means bit to, so if it were saying OSCCON.2 = true or OSCCON.2 = 1 then its the same as bsf OSCCON, 2 in assembly.
What does this chunk of the Example code do?
for(i = 0 ; i < 8 ; i++)
{
TX_MOSI = cmd.7;
TX_SCK = 1;
data2 = TX_MISO;
TX_SCK = 0;
cmd <<= 1;
while(TXIF == 0); //print out the status register before clearing stuff...==============================
TXREG = data2+48;
}
Clocks data into the chip using software SPI. I don’t know why they did it that way, as the MCU has hardware SPI.
Leon
Hmm. Wish they commented this better. I have no clue what the purpose of some of the things do. Whats the difference between Software SPI and Hardware? Besides the obvious.
Any one know how to Output and Input an Array properly?
See my code for details of how to do hardware SPI.
Leon