# SPIRead Question

**URL:** <https://forums.digi.com/t/spiread-question/38400>\
**Category:** Rabbit\
**Created:** [May 6, 2026, 6:01pm UTC](https://forums.digi.com/t/spiread-question/38400 "2026-05-06T18:01:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![3lionsCT](https://avatars.discourse-cdn.com/v4/letter/3/6a8cbe/32.png) [@3lionsCT](https://forums.digi.com/u/3lionsCT)\
**Post date:** [May 6, 2026, 6:01pm UTC](https://forums.digi.com/t/spiread-question/38400/1 "2026-05-06T18:01:43Z")

</div>

HI Guys,

I have a strange one. I am using a RCM6700 and using SPI port D. I have found that the very first time I call the function SPIRead it finishes after only issuing two of the 16 clock cycles. All subsequent SPIReads are fine. Its as if the SPIRead is not initialized correctly the first time. The obvious solution is to run a dummy SPIRead when th eprogram starts up but I was wondering if anyone else has come across this?

This is how I initialized Port D and I call SPIInit() prior to the first read

```auto
/ *************SPI Setup******************************************** /
#define SPI_MASTER
#define SPI_SER_D
#define SPI_CLK_DIVISOR 100
#define CLOCK_PORT D
#define SPI_RX_PORT SPI_RX_PC // Use Parallel Port C for SPI port D
#define CLOCK_BIT 0
#define SPI_CLOCK_MODE 0

```

Thanks

---

<div class="post-metadata">

**Author:** ![TomCollins](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.digi.com/tomcollins/32/37_2.png) [@TomCollins](https://forums.digi.com/u/TomCollins)\
**Post date:** [May 7, 2026, 6:24pm UTC](https://forums.digi.com/t/spiread-question/38400/2 "2026-05-07T18:24:14Z")

</div>

OK, this is an interesting one.

Maybe `SDCRShadow` has one of its top two bits set before you call `SPIInit()`? If so, it might be starting a transfer at that point. Can you print that shadow register value (in hex) before and after calling `SPIInit()`?

The other thought I have is to edit `SPIInit()` to move the “dummy read to empty the buffer” to the very end of the function, after it’s configured the registers.

It’s possible that somehow the state machine for reading 8 bits on that clocked serial port isn’t set up correctly, so the first read comes up short. Your solution of a dummy read after init is a good one, as long as it isn’t going to throw the slave devices off to have a single bit clocked out.

---

<div class="post-metadata">

**Author:** ![3lionsCT](https://avatars.discourse-cdn.com/v4/letter/3/6a8cbe/32.png) [@3lionsCT](https://forums.digi.com/u/3lionsCT)\
**Post date:** [May 7, 2026, 7:25pm UTC](https://forums.digi.com/t/spiread-question/38400/3 "2026-05-07T19:25:46Z")

</div>

Hi Tom,

As always, thanks for getting back to me.

I did a bit more digging and I am wondering if the Serial Port Status Register is the culprit?

I put some printf lines before and after the SPIInit and after the very first SPIRead (see below)

**SDCRShadow before SPIInit =00  
SDSR before SPIInit =0xc0**

**SDCRShadow after SPIInit but before 1st Read =0c  
SDSR after SPIInit but before 1st Read=0xc0**

**SDCRShadow after 1st Read =0c  
SDSR after 1st Read =0x00**

Notice how SDSR is 0xc0 before and after the SPIInit(). Bits 6 & 7 are set prior to the first SPIRead. According to the Serial Port x Status Register description, bit 6 should always be 0. Bit 7 indicates there is a byte in the receive buffer. I am wondering if the SDSR register should be cleared after first power up?

BTW I am using SPI.LIB version 1.09. Not sure if there is a newer version?

For now the dummy read works for me. I do it without the CS so the SPI slave doesn’t recognize it.

Regrads
