SPI OUT help!

evans_us

Member
Does anybody know how to send 16 bits using SPIout on 28x1? It appears from the manual that max is 8 bits but no example or instructions for additional bits. Any example code would be welcome. Can you use any of the PortB pins? or do you have to use the hardware pins?
Thanks Much for any help.
 

BCJKiwi

Senior Member
Hardware SPI only works on the dedicated hardware pins.
Shift(spi)in/out work on pins 0 -7 which are portB on the 28X1.

To shift more than 8 bits you need to send two bytes using the process described at the top and bottom of manual2 p156, with two bytes inside the (...) i.e. for 16 bits;
spiout 1,2,LSB_First, (b1 / 8, b2 / 8)
 

evans_us

Member
care with spiout

Thanks BCJ for the info.
I am using SPI to communicate with a digital pot (MCP42xxx)
It turns out that I had several problems all compounding.
It is important to ensure that MODE is set correctly : I was using mode 1 (msbfirst-l; low)and probably needed mode 5! mode 5 is MSBFirst_h.
Also I had this app working with a BS2 and "migrated" the code to the picaxe.
A note of caution if someone else does this is that the BS2 sends the commands in the opposite order using shiftout (dataout,clock,mode,data). The Picaxe uses spiout clock, dataout, mode, (data). I had not reset the parameters to be in the proper order which meant the dataout and clock were connected to wrong pins!
Finally I was trying to send a WORD as the data using word/16 as the data!
I have broken these into the bytes separated by a comma.
I'll try these fixes and see if this corrects the problem.
If this works I'll post a bit more info on the code and app.
 
Top