Go Down

Topic: Reading MOSI data from Bosch ASIC (Read 3 times) previous topic - next topic


SPI.transfer returns a byte result, capture those...
[ I won't respond to messages, use the forum please ]


SPI.transfer returns a byte result, capture those...

That's exactly what I'm trying to achieve - I just don't know the syntax or whatnot to achieve this, the SPI library page in the playground has no mention either...

Nick Gammon


Lots of datasheets have a description of the SPI protocol.  It doesn't mean you
have to implement it.

If the device works according to the SPI standards,    then the SPI implementation
on the Arduino should be able to talk to it.

If it doesn't,  give up.  I think it is beyond the capability of most people to identify the
problem, and how would you correct it, even if you could diagnose it ?

What this means,  is that you have to have the wiring correct.    And you have to be
making the correct calls from your arduino sketch to the functions of the SPI interface


Jan 25, 2013, 12:08 pm Last Edit: Jan 25, 2013, 09:10 pm by Nick Gammon Reason: 1

Brilliant, cheers. So, reading the text under heading "sending & receiving data", because the appropriate data is sent back is sent back at the same time as the data going out, let's check I understand this right.

SPI.transfer (4) would send the value of 4, of course - and writing an a = SPI.transfer(4) would capture the data returned as a result of sending a value of 4 out over SPI?

Code: [Select]
a = SPI.transfer (4);
// a is now 1

b = SPI.transfer (3);
// b is now 2

If I send my data as two binary bytes, as below for example, the data I then capture back using the above method, does that come back and save as a binary byte? I've added two entries in to my code to declare bytes to save the contents of the registers.

Code: [Select]

byte ident_reg_contents = B00000000;
byte diag_reg_contents = B00000000;

diag_reg_contents = SPI.transfer(B00000000);

If it doesn't,  give up

That somewhat defeats the point of learning to interface with the SPI bus....

Go Up