# SPI Master on RCM5400W

**URL:** <https://forums.digi.com/t/spi-master-on-rcm5400w/10173>\
**Category:** Rabbit\
**Created:** [October 9, 2008, 11:53pm UTC](https://forums.digi.com/t/spi-master-on-rcm5400w/10173 "2008-10-09T23:53:12Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![enricol](https://avatars.discourse-cdn.com/v4/letter/e/9de0a6/32.png) [@enricol](https://forums.digi.com/u/enricol)\
**Post date:** [October 9, 2008, 11:53pm UTC](https://forums.digi.com/t/spi-master-on-rcm5400w/10173/1 "2008-10-09T23:53:12Z")

</div>

hi all

I recently purhased an RCM5400W module with a RCM4000 prototype board. I’ve been trying to write an SPI Master dynamic C program using SPI.LIB and having some problems.

Here is my code:

```auto
#class auto
#use RCM54xxW.LIB

#define SPI_SER_B
#define SPI_CLK_DIVISOR 100
#define SPI_RX_PORT SPI_RX_PC

#use "spi.lib"

void main()
{
  char tx[3];
  char rx[2];
  
  tx[0] = 'A';
  tx[1] = 'B';
  tx[2] = 'C';

  brdInit();
  SPIinit();
  while(1)
  {
    BitWrPortI(PBDR, &amp;PBDRShadow, 0, 7);
    SPIWrite(tx, 3);
    SPIRead(rx, 2);
    BitWrPortI(PBDR, &amp;PBDRShadow, 1, 7);
  }
}

```

So I believe I’ve configured the following:  
PB7 = CS  
PB0 = CLK  
PC4 = MOSI  
PC5 = MISO

When I monitor the 4 pins from the scope, I can only see PB7 brought low and PB0 toggling. However, I don’t see PC4 moving at all. What’s wrong with my code?

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![carmenc](https://avatars.discourse-cdn.com/v4/letter/c/7ea924/32.png) [@carmenc](https://forums.digi.com/u/carmenc)\
**Post date:** [March 5, 2009, 2:05pm UTC](https://forums.digi.com/t/spi-master-on-rcm5400w/10173/2 "2009-03-05T14:05:53Z")

</div>

Hi,

I have the same problem with SPI on Port B as you. Did you find the solution?

I’ll be really gratefull if you answer me.

Best regards

---

<div class="post-metadata">

**Author:** ![enricol](https://avatars.discourse-cdn.com/v4/letter/e/9de0a6/32.png) [@enricol](https://forums.digi.com/u/enricol)\
**Post date:** [March 5, 2009, 5:37pm UTC](https://forums.digi.com/t/spi-master-on-rcm5400w/10173/3 "2009-03-05T17:37:54Z")

</div>

Hi Carmen,

That was awhile ago. If I recall correctly, I modified the SPI.LIB to make it work. Check the 2 attached file against the original SPI.LIB.

---

<div class="post-metadata">

**Author:** ![carmenc](https://avatars.discourse-cdn.com/v4/letter/c/7ea924/32.png) [@carmenc](https://forums.digi.com/u/carmenc)\
**Post date:** [March 6, 2009, 9:49am UTC](https://forums.digi.com/t/spi-master-on-rcm5400w/10173/4 "2009-03-06T09:49:56Z")

</div>

Hi,

For my module, SPI1.txt is perfect, now SPI is working properly.

Thank you very much

Carmen

---

<div class="post-metadata">

**Author:** ![karatsin](https://avatars.discourse-cdn.com/v4/letter/k/b9e5f3/32.png) [@karatsin](https://forums.digi.com/u/karatsin)\
**Post date:** [January 19, 2010, 4:37pm UTC](https://forums.digi.com/t/spi-master-on-rcm5400w/10173/5 "2010-01-19T16:37:22Z")

</div>

I am having this same problem and cannot access the file.

Could someone please re-up the file or post the changes made?

Thanks!

---

<div class="post-metadata">

**Author:** ![drngsh](https://avatars.discourse-cdn.com/v4/letter/d/b77776/32.png) [@drngsh](https://forums.digi.com/u/drngsh)\
**Post date:** [July 20, 2011, 4:13am UTC](https://forums.digi.com/t/spi-master-on-rcm5400w/10173/6 "2011-07-20T04:13:17Z")

</div>

Anyone has the zip file?..Pls help…

---

<div class="post-metadata">

**Author:** ![drngsh](https://avatars.discourse-cdn.com/v4/letter/d/b77776/32.png) [@drngsh](https://forums.digi.com/u/drngsh)\
**Post date:** [August 1, 2011, 8:21am UTC](https://forums.digi.com/t/spi-master-on-rcm5400w/10173/7 "2011-08-01T08:21:30Z")

</div>

Hi all,

Any kind soul would help me in the following: i am using 5600w and believe i have configured the following:  
PB7 = CS  
PB0 = CLK  
PC4 = MOSI  
PC5 = MISO  
Using the new SPi.lib posted here… the SPIwrite is perfect, writing 0xa,0xb,0xc. But at the receiver, i am unable to print out the data received.  
This is my coding and i do not know where went wrong and i don’t know if the SPI is reading in the data im writing unless i do a printf:

#define SPI\_SER\_B  
#define SPI\_RX\_PORT SPI\_RX\_PC  
#define SPI\_CLK\_DIVISOR 100  
#define SPI\_MASTER  
#use “SPITecnalia.LIB.lib”  
#use “rcm56xxw.lib”

char rx[3];  
void main()  
{  
brdInit();  
SPIinit();  
while(1)  
{  
SPIRead(rx,3); \<===  
printf("Received:%b  
",rx[2]); \<===  
}  
}

Any advices? Thank you!

Rds  
drngsh
