Hi Grant,
On Mar 15, 2011, at 7:52 AM, Grant Likely wrote:
>>
>> The problem that I am having is that the first bit of every SPI byte
>> transfer received from the slave zigbee module is a zero.
>>
>> For example, 0xEA when transmitted, comes out as 0x6A.
>>
>> Here is an example message transmit and receive sequence. The zigbee module
>> sends a zero for the first byte transferred, and then echoes the first byte
>> sent, as a response in a subsequent transfer, as an acknowledgement.
>>
>> Number of elements read from the firmware update file into the transmit
>> buffer = 16
>>
>> Displaying the contents of the transmit buffer array
>>
>> 55 10 00 EA 76 10 00 EA 7D 10 00 EA 84 10 00 EA
>>
>> Displaying the contents of the receive buffer array
>>
>> 00 00 55 10 00 6A 76 10 00 6A 7D 10 00 6A 04 10
>>
>> Number of bytes received = 16 bytes
>>
>> Similarily, 0x84 changes to 0x04.
>>
>> Looking at the binary representation,
>>
>> 0xEA = 1110 1010
>> 0x6A = 0110 1010
>>
>> 0x84 = 1000 0100
>> 0x04 = 0000 0100
>>
>>> From the above pattern, it looks like I'm losing the most significant bit
>>> for every 8-bit (1 byte) transfer.
>>
>> Looking at the data pattern, the ones that come back correctly are the ones
>> that don't need the 8th bit set to represent its value, e.g. 0x50, 0x10,
>> 0x00, etc.
>>
>> What could be causing the first bit stuck at 0 ?
>
> It could easily be a mismatch between the spi master and the spi slave
> on the transfer mode. Look for SPI_MODE_{0,1,2,3}, and compare it
> with what the zigbee module expects.
This was probably because of a protocol issue. The zigbee module expected one
byte transfers.
The following patch fixed the issue with single byte transfers. It was a bug in
the spidev_test.c program. After this was applied, using single byte transfers
with SPI_MODE1 worked.
http://git.kernel.org/?p=linux/kernel/git/longterm/linux-2.6.34.y.git;a=blobdiff;f=Documentation/spi/spidev_test.c;h=16feda9014692a87a4996bf51d759ab9e7500ee5;hp=10abd3773e49122aab0dfad27f7cb2c91b8d5d08;hb=95b1ed2ac7ffe3205afc6f5a20320fbdb984da92;hpb=dda04c7bcf58cb02ac796beb1cf483aa5277f2af
Elvis Dowson
------------------------------------------------------------------------------
Colocation vs. Managed Hosting
A question and answer guide to determining the best fit
for your organization - today and in the future.
http://p.sf.net/sfu/internap-sfd2d
_______________________________________________
spi-devel-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/spi-devel-general