Dangerous Prototypes

Dangerous Prototypes => Bus Pirate Support => Topic started by: sidhantgupta on August 13, 2010, 08:33:47 pm

Title: 16-bit word size SPI?
Post by: sidhantgupta on August 13, 2010, 08:33:47 pm
Hello!

I have been using this marvelous little hardware - Bus Pirate for some days now. First of all thanks for such an awesome tool!

I had a quick question that I can't seem to answer myself.

1. How do I do a 16-bit word size SPI read? I have tried [0xFF 0xFF], but that causes a gap between the clocks.

2. Then, I tried the 3-Wire Raw option. That seems to work, BUT, whatever command I give it, it does it *twice*. I am using the Open Logic Analyzer to probe it.
For example, if I give it [0xAA55] then on the logic analyzer I see:

CS LOW
16-bit data
CS HIGH
-- some delay --
CS LOW
Same 16-bit data
CS HIGH

To give some perspective, I am interfacing with a 12-bit ADC (AD7266). It needs CS pulled low, and then 16 clock cycles to get the data out. 12-bit data is padded with 0s on wither side of MSB and LSB to make it 16-bit.

Any help is appreciated.

Thank you!

SG
Title: Re: 16-bit word size SPI?
Post by: Sjaak on August 13, 2010, 08:47:08 pm
16 bit isn't supported (yet), but I wanted to implement it some day. I'm surprised you get 16 bits on the bus, you did set it manually with the ';'?

For now you can use the bitread command: http://dangerousprototypes.com/docs/Bus ... with_clock (http://dangerousprototypes.com/docs/Bus_Pirate_menu_options_guide#.21_Read_one_bit_with_clock)

Code: [Select]
[!:16]
Title: Re: 16-bit word size SPI?
Post by: sidhantgupta on August 13, 2010, 10:25:32 pm
Yes I used [0xAAAA;16]. That generated 16 bits but still reads in 8.

3WIRE> [0x5533]
/CS ENABLED
WRITE: 0x33;16
/CS DISABLED

I think it is a problem with the what is displayed. For example if I do:

3WIRE> [r]
/CS ENABLED
READ: 0x00;16
/CS DISABLED

On the Logic analyzer I see that it generates 16 clocks and MOSI data as 0x00FF, but chooses to display only the 2nd byte read.
Title: Re: 16-bit word size SPI?
Post by: Sjaak on August 13, 2010, 10:48:46 pm
only 1-8  bits is supported. I think I forgot to sanity check the input properly.

As said before I wanted to add 16 bits read/write to raw2/3wire. I put it on my list for firmware 5.7 (if space tolerates it ;))
Title: Re: 16-bit word size SPI?
Post by: garak on August 13, 2010, 11:12:51 pm
I ran into this problem a few days ago trying to interface an 8 input microchip 13bit ADC. It requires CS to be held low for 24 clock cycles, 4 bits of 0 are transmittted, then 5 bits for the start of conversion and input selection, then on the last 13 clock cycles the result is outputted from the chip. So I need to output 24bits while reading 24 bits.
Title: Re: 16-bit word size SPI?
Post by: ian on August 14, 2010, 09:40:24 am
What is the functional difference between the 16bit read and 'rr' or 'r:2' ?

@garak - I think you can enable read&write mode and send {0b0000xxxx 0bx0000000 r}, maybe also {0;4 xx;5 r;7 r} (where XX is the command). It's not super elegant, but neither is the protocol Microchip choose :)

( ! ) Fatal error: Uncaught exception 'Elk_Exception' with message 'Please try again. If you come back to this error screen, report the error to an administrator.' in /var/www/dangerousprototypes/forum/sources/database/Db-mysql.class.php on line 696
( ! ) Elk_Exception: Please try again. If you come back to this error screen, report the error to an administrator. in /var/www/dangerousprototypes/forum/sources/database/Db-mysql.class.php on line 696
Call Stack
#TimeMemoryFunctionLocation
10.00942053160session_write_close ( )...(null):0
20.00972184736ElkArte\sources\subs\SessionHandler\DatabaseHandler->write( )...(null):0
30.00972185512Database_MySQL->query( ).../DatabaseHandler.php:119
40.05392324232Database_MySQL->error( ).../Db-mysql.class.php:273