1

I want to to execute the SPI protocol operation using GPIO Pins, want to configure to single slave operation, in which way I have to configure that, I am using STM32F100RB Microcontroller and Coocox IDE for this executing in windowsxp.

if any body have example source code regarding the configuration of SPI Protocol operation using GPIO pins, then please send me that. it very helpful for my project, Thanks in advance.

Regards, Pavan Neo.

Clifford
  • 88,407
  • 13
  • 85
  • 165
Pavan Koneru
  • 21
  • 1
  • 2
  • That's not the way this site works. We will help you with specific problems you have in code that you have written. But no one will just give you a working solution based on vague requirements. Have a look around the [FAQ](http://stackoverflow.com/help). – embedded.kyle Oct 24 '13 at 13:53
  • yes it is very common to do spi that way, I would assume more-so than using spi specific logic... – old_timer Oct 24 '13 at 14:05
  • 1
    Yes it is possible, however you have several hardware SPI peripherals on that chip for which there should be examples in the ST support materials. – Chris Stratton Oct 24 '13 at 14:44
  • 1
    SPI is a very simple protocol, does it really require an example? If you can set and clear GPIO bits you can implement it form a timing diagram. But as @Chris says, you could use an available on-chip SPI peripheral. – Clifford Oct 24 '13 at 18:58
  • 1
    Check application notes from the MCU manufacturer. There is usually one describing how to implement a software SPI for a given MCU. That being said, how on earth did you manage to specify a MCU _without_ SPI? It is next to impossible to find such a MCU on the market. And then when you [RTFM](http://www.st.com/st-web-ui/static/active/en/resource/technical/document/datasheet/CD00251732.pdf) it says you have 2 hardware SPI peripherals. Why can't you use them? – Lundin Oct 25 '13 at 06:17

1 Answers1

5

You're asking about Bit banging. This is the process of using an IO (or several) to encode or decode a serial signal. Wikipedia has a good description of this process.

For SPI specifically, you will need two or three outputs (depending on whether or not chip select is needed) and one input. You'll have to ensure that your bits are set or read in the correct order to not violate any setup/hold requirements of your peripheral, and you'll need to pay attention to the polarity needed on the clock signal (to make sure you're reading/writing data on the correct edge).

The Wikipedia link has some example code for bit banging that you may find useful as a starting point.

rjp
  • 1,760
  • 13
  • 15