SPI question

Hi guys!
I recently bought an ISD4002 (IC used for recording and playing audio) and it works with SPI. Now, I have a picaxe 28x1 and was trying to interface it with the ISD chip. In the ISD's manual it says:

It is necessary therefore to shift in HEX address 20, <0010 0000>....
The input byte, <0010 0000>, is to be clocked in, right to left.

And then it shows this example to understand how the right-to-left shifting works:

MCU ---> ISD

<0010 0000> ---> <0000 0000>
<0001 0000> ---> <0000 0000>
<0000 1000> ---> <0000 0000>
<0000 0100> ---> <0000 0000>
<0000 0010> ---> <0000 0000>
<0000 0001> ---> <0000 0000>
<0000 0000> ---> <1000 0000>
<0000 0000> ---> <0100 0000>
<0000 0000> ---> <0010 0000>

and then it says:

Note that some microcontrollers with hardware SPI ports only have the ability to do a left to right shift. Consult the &#956;P data sheet for details. If this is so, then the bit placement of the data shifted in would have to be inverted.

My question is: is there a way to know how the SPI works for the picaxe? Do i just have to use hspiout the normal way (regarding the above example, i'll just input the data <0010 0000>) ?

Thank you :)
 

hippy

Ex-Staff (retired)
The SHIFTOUT (SPIOUT) command gives you full control over which goes out first, and you have that control if using bit-banged code. Take a look at Manual 2 and there's may be some ISD example code on the forum already.
 
Thanks for that. I was just looking at the hardware way because it seemed faster. If i well understood what the ISD's datasheet says, i'll have to use the option "LSB first, MSB last".
 

westaust55

Moderator
hardware SPI solution ?

Since you have the 28X1 PICAXE chip with hardware SPI capability, if using the HSERSETUP with the HSERIN and HSEROUT commands,
one way to get the lsb (least significant bit) out first might be to use the REV command to reverse the order of the 8 bits. It does mean you need to put the values into a variable first.


REV = reverse a number of bits:
let b1 = %10110000 REV 8
 

westaust55

Moderator
Turns out that the HSEROUT command, sends out the lsb first


Could not find it stated in the PICAXE manuals = something worth adding to the manuals .

From the PIC 16F886/7 datasheet from Figure 12.1 and Figure 12. the lsb is in fact transmitted first.

So, would seem that you may/will not need the REV command.
 

hippy

Ex-Staff (retired)
There seems to be some confusion here between high speed serial and high speed SPI.

The specification for serial data transfer ( as per RS232 etc ) is industry standardised as lsb first so there's little requirement to add that to the manual.

High speed SPI uses the PICmicro MSSP in and data is clocked in and out msb first.
 
I did it the REV way and it worked. It can now record and play files even if not properly, but that problem is not related to SPI.

Thanks everyone for your help!
 
Top