2

I have a ts7800 SBC, and I need to communicate over an SPI bus. In their documentation they say that their is no hardware SPI, and they implement in their sample code "software SPI." For me, this works now but when I view the SPI clock on an oscilliscope, it looks uneven(typically the clock stays higher for a longer period of time than it stays low, but sometimes the opposite). I am worried that when I start adding more threads and code into the mix, the problems with the SPI being software controlled will become more apparent. Has anyone dealt with an issue like this before, and what did you do to correct it? Or was it even an issue?

I would rather not use interupts for the SPI bus because I have just as important (if not more important) processes going on in the other threads.

Thank you for your help.

Reid
  • 2,030
  • 1
  • 21
  • 38

2 Answers2

6

There is no problem here since SPI is synchronous. Data is transferred on clock edges. As long as the minimum setup and hold times are observed, there should be no problem. Randomly stretching out sections of a SPI waveform should be irrelevant to properly implemented SPI devices.

Olin Lathrop
  • 310,974
  • 36
  • 428
  • 915
4

This looks like there are interrupts occurring during the SPI communication. If it worries you disable interrupts before you start SPI and re-enable them afterwards. Not that it should worry you: unlike UART which is timing-critical SPI is clocked, and the clock's edges determine when a bit is shifted in/out. You can stretch clock pulses for an indefinite time if you want.

stevenvh
  • 145,145
  • 21
  • 455
  • 667