I am trying to read Maxim 13362 chip, using rabbit (RCM 5700) through SPI communication. On the datasheet for the chip it states, Configure SPI for CPOL = 0, CPHA = 1, SCLK = 4Mhz.
I am able to make SCLK 4 Mhz, but do not know how to declare CPOL = 0 and CPHA = 1. Here is the code till the declaration:
#class auto
#define SPI_SER_C
#define SPI_CLK_DIVISOR 12.5
#define SPI_RX_PORT SPI_RX_PC
#use “spi.lib”
unsigned char register00[4];
unsigned char register10[4];
unsigned char register01[4];
unsigned char readingreg[4];
Can anyone direct me on how you declare these things in rabbit?
The following is a description of the values which the user may define
BEFORE the #use SPI.lib statement:
(1) Interface (default is SPI_SER_B)
SPI_SER_A use serial port A
SPI_SER_B use serial port B
SPI_SER_C use serial port C
SPI_SER_D use serial port D
SPI_CLOCK_MODE clock and data phase
SPI_RX_PORT define to one of the following to select which parallel
port is used for the receive bit
SPI_RX_PC if using parallel port C
SPI_RX_PD if using parallel port D
SPI_RX_PE if using parallel port E
SPI_SLAVE defines the Rabbit as a slave device
This signal is generated by the Slave to tell the
Master that the slave is ready. It is used for
handshaking between each byte.
SPI_SLAVE_RDY_PORT defines the port for SLAVE_RDY signal
SPI_SLAVE_RDY_SHADOW defines the shadow register for SPI_SLAVE_RDY_PORT
SPI_SLAVE_RDY_BIT defines the bit for the SLAVE_RDY signal
This signal is read by the slave and is used by it
to determine that it has been enabled by the Master.
SPI_SLAVE_CS_REG defines the register for the incoming CS signal
SPI_SLAVE_CS_BIT defines the bit for the incoming CS signal - Low True
SPI_SLAVE_HIGH_TRUE define if high true chip select is desired
This signal is generated by the Master.
The user is responsible for setting/clearing this
bit before/after every transaction.
MASTER OPERATION: If SPI_MASTER_CS_PORT is defined it
will be toggled during the data transfer. The value of
SPI_SLAVE_HIGH_TRUE is used to determine the true state.
SLAVE OPERATION: If SPI_MASTER_CS_PORT is defined the
slave receive function will use the CS input for
handshaking between each byte.
SPI_MASTER_CS_PORT define CS port from master to Slave
SPI_MASTER_CS_SHADOW define shadow register for CS (Master only)
SPI_MASTER_CS_BIT define CS bit number
(2) SPI Bit Rate Divisor (default is 5)
SPI_CLK_DIVISOR This is the divisor for the appropriate Timer A register.
Warning: a small value for the SPI_CLK_DIVISOR can result in unstable operation.
Recommendation is that values should be >= 5.
NOTE: this library uses the dedicated bit rate divider - not timer A.
SPI_CLOCK_MODE is set to the following values found in the Rabbit 5000 processor manualm see Figure 17-1. Serial Ports A – D Operation in Clocked Serial Mode.
MODE 00
MODE 01
MODE 10
MODE 11
so, #define SPI_CLOCK_MODE to 0 through 3.
You might also find the TN200 SPI Using the Rabbit Clocked Serial Ports useful.
http://ftp1.digi.com/support/documentation/0220038_f.pdf