Reply by Shawn Upton March 28, 20112011-03-28
When I've done it, I've just done it in a while loop, although for this example I think this psuedo code would do the trick:

for(i=0;i<=7;i++)
{
if (data&(0x1<<i))
{data=true;}
clk=true;
clkse;
datase;
}

Of course, modify for however many bits need to go out, etc.  Very simple, very useful--I've used it a number of times.  Works very well if the device requires a non-integer number of 8 bits to control it.

Shawn Upton, KB1CKT

NAQCC 4723
Reply by Dave McLaughlin March 28, 20112011-03-28
Bit banging is quite easy to do but we need to know more about the device
you are needing to use the SPI with and what you have tried so far?

Have you tried the built in SPI or are you limited to different IO pins?
What Rabbit module are you using?

I did an SPI bit bang for an FTDI USB host controller simply because I had
no spare hardware SPI or serial port and it is quite easy to do once you
know the way the SPI is designed to work for your device. Study the
datasheet and write a function to send a byte or bytes to the device and
another to read the SPI out. Quite simple with FOR loops and masking etc. If
your device is not required to be ultra fast you can do this in simple C
code without the need to do assembly.

Let us know more first?

Dave...
---
Very funny Scotty, now beam down my clothes!!!
---
Reply by eilidhs_daddy March 28, 20112011-03-28
You'll get mnore help if you tell us what module you are using, what code you have tried so far and what issues you are facing.

If you have Dynamic C installed then you should already have some SPI sample code. Have you tried that? How did it go?

-K
Reply by saadkhalid_26 March 28, 20112011-03-28
hi,
i need help to write bitbang SPI code for MSP and i need help quickly.
thankyou in advance