My understanding of the ATtiny13 datasheet is that although you can ISP the micro via "SPI" it actually doesn't have the functionality to operate on an SPI bus with other devices (at least not in hardware). Is that right?


Like all AVRs, the ATtiny13 uses SPI for programming. However, it doesn't have an actual SPI port that can be used in applications. Software SPI could be implemented, of course, and Atmel has an app note on the technique:



SPI is the simplest synchronous serial protocol you can think of, and since it requires only a shift register one could wonder why it isn't implemented in the ATtiny. At the same time the protocol's simplicity offers a solution: bit-banging. SPI is simpler to bit-bang than UART, where you have to worry about timing, or Manchester.
So the reason SPI is used for programming is that it's simple and reliable. The reason why it's not implemented in hardware is that it can easily be emulated in software.

  • \$\begingroup\$ Interesting; I was aware of bitbanging libraries, but had assumed that the performance would not be good enough to talk to many other devices; I am not yet familiar enough the the protocol to know how much of an issue this would be, but it sounds like not much. Thanks! \$\endgroup\$ – Chinasaur Jul 1 '11 at 20:32
  • \$\begingroup\$ @Chinasaur - Like I said, with SPI you don't have to worry about timing. As SPI master you provide the clock pulses, so it doesn't matter if one of them comes a bit later. \$\endgroup\$ – stevenvh Jul 2 '11 at 4:35
  • \$\begingroup\$ Hardware SPI on an attiny would be more than just the shift register, it needs more registers to control it, an entry in the vector table and routing for another hardware interrupt, routing of an independent clock to the SPI clock pin and running the clock independently of what the main CPU thread is doing. For a CPU where they went as far as providing only 64 bytes of ram in terms of cost savings, dropping SPI probably saved them more than the entire RAM size. \$\endgroup\$ – John Meacham Jul 2 '14 at 19:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.