Chameleon-PIC Nurve Networks, Chameleon-PIC Datasheet - Page 167

MCU, MPU & DSP Development Tools PIC24 & PROPELLER DEV SYSTEM (SBC)

Chameleon-PIC

Manufacturer Part Number
Chameleon-PIC
Description
MCU, MPU & DSP Development Tools PIC24 & PROPELLER DEV SYSTEM (SBC)
Manufacturer
Nurve Networks
Datasheet

Specifications of Chameleon-PIC

Processor To Be Evaluated
PIC24
Data Bus Width
16 bit
Interface Type
USB, VGA, PS/2, I2C, ISP, SPI
Operating Supply Voltage
3.3 V, 5 V
Lead Free Status / RoHS Status
Lead free / RoHS Compliant
}
Notice that we always assert then de-assert the chip select line, so that the SPI device comes online. In some case, you
might want to keep the SPI device selected (enabled) at all times as long as you don’t have other SPI devices on the bus
that can contend with the SPI interface.
_________________________________________________________________________________________________
Function Prototype:
Description:
parameter (if provided) will contain whether the return value contained a valid SPI byte received.
Example(s):
_________________________________________________________________________________________________
Function Prototype:
Description:
single function is what is used to send and receive information to and from the Propeller chip. Each command has 3-byte
always. The first byte cmd is the command 0..255 that represents what you want to do. These are the same commands
that are listed in the header file and the CHAM_DEFAULT2_DRV_V112.SPIN message dispatcher is listening for. The
second byte data is the first 8-bit data operand, the 3
require 16-bits, then data and status are concatenated to form a 16-bit operand like this:
Thus, data is the lower 8-bits and status is the upper 8-bits.
For commands that only require 8-bit operands set status to 0. If you recall, SPI is a “circular” buffer system, so each byte
we send out, we receive a byte back, thus when you call this function, 3 bytes are sent, 3 bytes are received. Currently,
the function returns a 16-bit value representing the first two returned bytes, the 3
since this is such an important function, let’s take a look at the source for it:
// this function waits for any previous command to complete and then initiates a new command
long SPI_Prop_Send_Cmd(int cmd, int data, int status)
{
} // end SPI_Prop_Send_Cmd
As you can see the SPI_Prop_Send_Cmd(…) function waits on a flag while calling a hidden function that actually does
the work. Let’s talk about that for a moment. In multiprocessor systems, when one processor requests another processor
to do something, the whole point of multiprocessors, is that the originating processor can continue to do more work in
“parallel”. Thus, we need code to consider this such that say processor A (the PIC) sends a command to the processor B
(the Propeller). Now, processor A goes about its business while processor B executes the command. But, the processor A
finishes something and then requests processor B to do something else – here is the problem. Processor B can’t perform
another function until it completes the last requested command, thus we need a mechanism that blocks processor A and
// Deselect device on CS1 by selecting CS0
SPI_SET_CS(SPI_CS_0)
// wait for previous command to complete
while (SPI_Prop_Send_Cmd2(CMD_NULL, 0, 0) & 0x00ff0000)
// initiate the new command
return SPI_Prop_Send_Cmd2(cmd, data, status) & 0x0000ffff;
void SPI_Write(unsigned char data8);
unsigned char SPI_Read(unsigned char *Success);
long SPI_Prop_Send_Cmd(int cmd, int data, int status);
msb [status, data] lsb
;
None.
These functions simply write/read a byte to/from the SPI port. In the case of SPI_READ(…) the Success
SPI_Prop_Send_Cmd(…) is the workhorse of the entire inter-processor communications system. This
rd
byte status is the 2
© 2009 NURVE NETWORKS LLC “Exploring the Chameleon PIC 16-Bit”
nd
8-bit data operand. For commands that
rd
byte is used internally for now. Also,
167

Related parts for Chameleon-PIC