Continue to Site

# Implementing SPI interface in codes

Status
Not open for further replies.

#### mrinalmani

Hi
Our project requires an MCU to communicate with a device over the SPI.
The budget for the end product is very tight and MCUs with embedded SPI are slightly expensive.

Is it possible (easily) to implement SPI programmatically?
Data rate is irrelevant, a few kbps will do.

Thank you

#### chandu.kurapati

##### Full Member level 3
Hi,

Is it possible (easily) to implement SPI programmatically?

ya, it is possible to implement the protocol programmatically with GPIO pins,
concept to implement a protocol with GPIO's is called bit banging.

Check bit banging concept on wiki, then you come know about it..

Data rate is irrelevant, a few kbps will do

Data rate is depends on the GPIO speed, anyway it is controller peripheral
can work with some kbps, we should check it...

mrinalmani

### mrinalmani

Points: 2

#### FvM

##### Super Moderator
Staff member
Software (bit-banging) SPI examples can be found for any CPU and have been often discussed at Edaboard. I believe you can also write it from the scratch within minutes if you know the required SPI mode (clock polarity and phase).

#### chandu.kurapati

##### Full Member level 3
Hi,

ya, it is depends on the selected slave SPI mode(clock polarity & phase).

If you know that can implement bit banging with GPIO's.

#### matrixofdynamism

Just remember that when doing software SPI, a lot of time will be spent by the processor in wiggling the lines up and down.

#### Aussie Susan

... and MCUs with embedded SPI are slightly expensive.
I would question this.
You don't say what type of MCU you are looking at but even the basic ones in many manufacturer's range have a hardware SPI.
Susan