EmbeddedRelated.com
Forums
Memfault Beyond the Launch

SPI on RCM3750

Started by henr...@analog.com February 15, 2012
Hello,
I am using RCM3750 for SPI connection testing. Using: PB0 for CLK, PD4 for MOSI, PD5 for MISO andPB7 to CS.
Here is my code:
#define SPI_MASTER
#define SPI_SER_B
#define SPI_CLK_DIVISOR 100
#define SPI_CLOCK_MODE 0
#define SERB_USEPORTD
#use "spi.lib"

void main()
{ char data_read[2];
char te,te1 ;
int k,k1;
SPIinit();
te = 0x20;
te1 = 0x09;

while(1)
{
costate{

SPIWrite(&te,1);

SPIRead(data_read2, 2);
printf("SPI bytes1 = %x \n", data_read2[0]);
printf("SPI bytes1 = %x \n", data_read2[1]);
waitfor(DelaySec(5));
}
}
}
It did not work. Maybe I missed somthing? I am new to SPI. Please help. Thanks

On 2/15/2012 12:11 PM, h...@analog.com wrote:
> Hello,
> I am using RCM3750 for SPI connection testing. Using: PB0 for CLK, PD4 for MOSI, PD5 for MISO andPB7 to CS.
> Here is my code:
> #define SPI_MASTER
> #define SPI_SER_B
> #define SPI_CLK_DIVISOR 100
> #define SPI_CLOCK_MODE 0
> #define SERB_USEPORTD
> #use "spi.lib"
>
> void main()
> { char data_read[2];
> char te,te1 ;
> int k,k1;
> SPIinit();
> te = 0x20;
> te1 = 0x09;
>
> while(1)
> {
> costate{
>
> SPIWrite(&te,1);
>
> SPIRead(data_read2, 2);
> printf("SPI bytes1 = %x \n", data_read2[0]);
> printf("SPI bytes1 = %x \n", data_read2[1]);
> waitfor(DelaySec(5));
> }
> }
> }
> It did not work. Maybe I missed somthing? I am new to SPI. Please help. Thanks
>

I don't see any code or defines to set up the CS line.

We would need more than "it did not work". Do you get a clock? does it
return any data? Code locks up?

--
------
Scott G. Henion, Consultant
Web site: http://SHDesigns.org
------

Hi,
I monitor the MOSI and did not see any thing?, how to define the CS line? Thanks

________________________________
From: r... [mailto:r...] On Behalf Of Scott Henion
Sent: Wednesday, February 15, 2012 12:29 PM
To: r...
Subject: Re: [rabbit-semi] SPI on RCM3750

On 2/15/2012 12:11 PM, h...@analog.com wrote:
> Hello,
> I am using RCM3750 for SPI connection testing. Using: PB0 for CLK, PD4 for MOSI, PD5 for MISO andPB7 to CS.
> Here is my code:
> #define SPI_MASTER
> #define SPI_SER_B
> #define SPI_CLK_DIVISOR 100
> #define SPI_CLOCK_MODE 0
> #define SERB_USEPORTD
> #use "spi.lib"
>
> void main()
> { char data_read[2];
> char te,te1 ;
> int k,k1;
> SPIinit();
> te = 0x20;
> te1 = 0x09;
>
> while(1)
> {
> costate{
>
> SPIWrite(&te,1);
>
> SPIRead(data_read2, 2);
> printf("SPI bytes1 = %x \n", data_read2[0]);
> printf("SPI bytes1 = %x \n", data_read2[1]);
> waitfor(DelaySec(5));
> }
> }
> }
> It did not work. Maybe I missed somthing? I am new to SPI. Please help. Thanks
>

I don't see any code or defines to set up the CS line.

We would need more than "it did not work". Do you get a clock? does it
return any data? Code locks up?

--
------
Scott G. Henion, Consultant
Web site: http://SHDesigns.org
------
I am using SPIWrite() from SPI.LIB and just wonder if it sends MSBit first or LSBit first? Please help. If you have any function to send MSBit first, I greatly appreciate it.
On 2/18/2012 1:15 PM, h...@analog.com wrote:
> I am using SPIWrite() from SPI.LIB and just wonder if it sends MSBit first or LSBit first? Please help. If you have any function to send MSBit first, I greatly appreciate it.
>

The rabbit 3K does not have a way to sen MSB first, it is done via software.

The lib functions will reverse the bytes unless SPI_NOREV is defined
before the lib is #use'd.

--
------
Scott G. Henion, Consultant
Web site: http://SHDesigns.org
------


Memfault Beyond the Launch