# SPIRead library function hangs

**URL:** <https://forums.digi.com/t/spiread-library-function-hangs/15964>\
**Category:** Rabbit Software\
**Tags:** hang, dynamicc10, spi\
**Created:** [December 21, 2015, 9:00am UTC](https://forums.digi.com/t/spiread-library-function-hangs/15964 "2015-12-21T09:00:39Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![bflusche](https://avatars.discourse-cdn.com/v4/letter/b/e480ec/32.png) [@bflusche](https://forums.digi.com/u/bflusche)\
**Post date:** [December 21, 2015, 9:00am UTC](https://forums.digi.com/t/spiread-library-function-hangs/15964/1 "2015-12-21T09:00:39Z")

</div>

I am using the DC 10.72 SPIRead library function to read out the temperature and humidity from a device. After several tens of thousands of readings (sometimes less iterations, sometimes more) the program hangs in the SPIRead function.

Anyone have this issue and solution?

The default settings (which I am using) are on Port B. PB0 is used for the serial flash clock. Possible conflict and source of my hang?

---

<div class="post-metadata">

**Author:** ![bflusche](https://avatars.discourse-cdn.com/v4/letter/b/e480ec/32.png) [@bflusche](https://forums.digi.com/u/bflusche)\
**Post date:** [January 4, 2016, 8:05am UTC](https://forums.digi.com/t/spiread-library-function-hangs/15964/2 "2016-01-04T08:05:01Z")

</div>

The problem appears to be the library using Serial Port B with the clk on PB0. I hooked up a scope and saw clock activity on the line even with my SPI routine disabled. Something else is periodically clocking 2 bytes. The literature says the serial flash uses the line at INIT, but not after. Something is using it though. I wrote a bit-bang routine and used PB4 for the clock, works like a champ now.

---

<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:** [January 20, 2016, 2:42pm UTC](https://forums.digi.com/t/spiread-library-function-hangs/15964/3 "2016-01-20T14:42:42Z")

</div>

What product was this? There are a few SPI-related bug fixes in the GitHub repository:

[https://github.com/digidotcom/DCRabbit\_10/commits/master](https://github.com/digidotcom/DCRabbit_10/commits/master)

If you make use of the UserBlock on products that boot from a serial flash, they will access the SPI bus.

---

<div class="post-metadata">

**Author:** ![bflusche](https://avatars.discourse-cdn.com/v4/letter/b/e480ec/32.png) [@bflusche](https://forums.digi.com/u/bflusche)\
**Post date:** [January 24, 2016, 2:20am UTC](https://forums.digi.com/t/spiread-library-function-hangs/15964/4 "2016-01-24T02:20:07Z")

</div>

Dynamic C 10.72 and RCM 5650. To my knowledge, I am not using User Blocks, but perhaps the WiFi routines are accessing calibration data?

---

<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:** [January 25, 2016, 12:37am UTC](https://forums.digi.com/t/spiread-library-function-hangs/15964/5 "2016-01-25T00:37:35Z")

</div>

Is there an ADC on the 5650? Take a look at the schematic and you should be able to see what devices are on the SPI bus and might be in use. And you could just make use of the SPI semaphore in your own code to ensure that there aren’t any SPI conflicts. Just make sure you have the semaphore before asserting chip select on your device.

---

<div class="post-metadata">

**Author:** ![petermcs](https://avatars.discourse-cdn.com/v4/letter/p/4af34b/32.png) [@petermcs](https://forums.digi.com/u/petermcs)\
**Post date:** [January 25, 2016, 5:46am UTC](https://forums.digi.com/t/spiread-library-function-hangs/15964/6 "2016-01-25T05:46:27Z")

</div>

Looking at the schematic at [http://ftp1.digi.com/support/documentation/0900280\_f.pdf](http://ftp1.digi.com/support/documentation/0900280_f.pdf)

There is an ADC also connected to the SPI interface so using the semaphore would be a must.
