Bit bang SPI is SLOW

jessejay356

New Member
I have a 18x picaxe. I am using a bit bang SPI interface. It is VERY SLOW! Anyway to improve this? I'm getting a rate of like 192 bytes per second with SPI. :( I need a rate of at least 10 times that. The 16f88 that the picaxe 18x is based on has native SPI capibility... any way to access that? BTW, I already am running at 8mhz.

 

hippy

Ex-Staff (retired)
To get 1920 bytes per second throughput, that's 65uS per bit, far quicker than it takes to execute a PICAXE command. You can get closer to that by putting the byte to transfer out in 'b0' and by clever choice of Data Pin ...

- SYMBOL DAT = pin0 ' Pin 0 is SPI Data
- SYMBOL CLK = 1 ' Pin 1 is SPI Clock
-
- SpiOut:
- DAT = bit0 : PULSOUT CLK,1
- DAT = bit1 : PULSOUT CLK,1
- <i>: </i>
- DAT = bit7 : PULSOUT CLK,1
- RETURN

Edited by - hippy on 12/06/2006 19:38:35
 

womai

Senior Member
The fact that you have to manually bit-bang SPI connections has been one of my complaints for a while. The workaround for me has been to look for replacement peripheral chips that use I2C instead - the Picaxe can do this natively at 400 kHz. The added advantage is that I2C makes for pretty easy expansion of your system since it uses only two pins no matter how many chips are on the line (wheras SPI needs a dedicated enable line per chip). I was able to find good solutions for ADCs, DACs, I/O expanders (are I2C anyway), etc. etc. The only downside seems to be that many of them are not available as DIP packages (bad for prototyping on a breadboard) but on the other hand once I got comfortable using surface mount I tend to like it because it needs less space and is faster to solder (though needs some practice).

The other thing is that when I whined about lack of SPI and other things, Rev-Ed's (i.e. &quot;Technical&quot;'s) response was that they are working on a new generation of Picaxes, based on Microchip's 18F series, that will have native SPI and many more goodies (much more variables, much more RAM, interruptable hardware-serial-port, etc.). If their schedule still holds that will become availabe third quarter this year. Can't wait to get my hands on those devices!

Wolfgang


Edited by - womai on 12/06/2006 21:14:32

Edited by - womai on 13/06/2006 00:32:57
 
Top