# SPI Issue, RCM4010

**URL:** <https://forums.digi.com/t/spi-issue-rcm4010/11080>\
**Category:** Rabbit\
**Created:** [February 2, 2009, 4:41pm UTC](https://forums.digi.com/t/spi-issue-rcm4010/11080 "2009-02-02T16:41:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![MGaidica](https://avatars.discourse-cdn.com/v4/letter/m/43a26b/32.png) [@MGaidica](https://forums.digi.com/u/MGaidica)\
**Post date:** [February 2, 2009, 4:41pm UTC](https://forums.digi.com/t/spi-issue-rcm4010/11080/1 "2009-02-02T16:41:50Z")

</div>

I am having a really tough time getting any data out on my SPI port. Using this:

#class auto

#define SPI\_SER\_B  
#define SPI\_CLK\_DIVISOR 500

#use spi.lib

void main()  
{  
char reading[2];  
char sending[2];

sending[0] = 0x0F;  
sending[1] = 0xF0;

```
SPIinit();

```

while(1)  
{  
SPIWrRd(sending, reading, 2);  
printf(" Sending 0x%x 0x%x  
Reading 0x%x 0x%x

", sending[0], sending[1], reading[0], reading[1]);  
}  
}

This is just a simple test. I am using the RCM4010 on the dev board right now. I can see my clock on portb.0, I can read data fine on portc.5, but on portc.4 I can not get anything to move, it just sits at ground. Any ideas? Thanks.

---

<div class="post-metadata">

**Author:** ![MGaidica](https://avatars.discourse-cdn.com/v4/letter/m/43a26b/32.png) [@MGaidica](https://forums.digi.com/u/MGaidica)\
**Post date:** [February 2, 2009, 8:52pm UTC](https://forums.digi.com/t/spi-issue-rcm4010/11080/2 "2009-02-02T20:52:17Z")

</div>

Turns out the SPI.LIB doesnt setup the Port C Function Register (PCFR), or it did it incorrectly. When I read it I got a value of 0xC0, showing pins C6 and C7 (used to communicate with computer) were setup for special functions, when serial channel B SPI uses C4 and C5. As to why I could still read my SPI through C5 and not write to C4 I have no idea. It comes out to:

#class auto

#define SPI\_SER\_B  
#define SPI\_CLK\_DIVISOR 500

#use spi.lib

void main()  
{  
char reading[2];  
char sending[2];

sending[0] = 0x0F;  
sending[1] = 0xF0;

```
SPIinit();

```

BitWrPortI(PCFR, &PCFRShadow, 1, 4);  
BitWrPortI(PCFR, &PCFRShadow, 1, 5);

sending[0] = 0x55;  
sending[1] = 0x0F;

while(1)  
{  
SPIWrite(sending, 2);  
SPIRead(reading, 2);  
printf(" Sending 0x%x 0x%x  
Reading 0x%x 0x%x

", sending[0], sending[1], reading[0], reading[1]);  
}  
}

Just wrote to two bits after the SPIinit().
