I’m trying to interface with my custom SPI slave board. In synchro mode I achieved normal SPI transfer, but in asynchronous mode I couldn’t get SPI read working. The problem looks like this: when I write to SPI in asynchronous mode and wait for a flag from high level IRQ - the transfer passes and I see that my SPI slave got data. When I read from SPI in asynchronous mode I get valid data but than my slave boards does not respond.
It seems that in asynchronous mode something differs: timings or delays or addressing…
I’m not sure what you mean by Synchronous and asynchronous SPI. Could you please elaborate a little further.
However, in my experience the following is true for a Q2686 running firmware R7.2 & R7.3:
The Q2686 has to be the SPI MASTER (i.e. controls the bus at all times)
The Q2686 does not handle simultaneous bi-directional SPI data (i.e. for every byte clocked out on the MOSI pin, another is read on the MISO pin). All microcontroller implementations of SPI that I have worked with WILL support simultaneous bi-directional data transfer
I haven’t pushed the R7.4 firmware yet - but when my next PCB’s come back I’ll be looking int the SPIU again.
In SPI sample there is a switch from synchronous to async SPI and vice versa. Synchronous SPI waits for every transfer to complete before it proceeds the next program step so it may be easily reseted by watchdog if it is expected to read too much data. Asynchronous transfer is IRQ based and therefore it is OK to send or read large buffers of data.
I know. I’ve got a SPI slave board connected to my Q2686. BTW I’ve got R74.
Yes it is a bit weird for me. My SPI slave can read and write simultaneously, but it waits for Q2686 transfers.
Also I’d like to know is it OK to expect all zeroes or all ones on MOSI during Q2686 read? And also do you have some kind of emergency reset for unexpected desynchronization? It seems to me that every unexpected or lost byte can hang up the slave since there is no any byte synchronizations.
it mostly indicates a problem, but why not?
it’s normal to read zero-filled bytes from my accellerometer sometimes.
you’ve got chip-select for that don’t you?
if chip-select switches to -not-selected- (logic state depends on the spi-mode) communication should reset.
if chip-select switches back to -selected- the communication should start again from the beginning.
That’s what I thought - I thought blackyblack was referring to the SPI protocol itself - and I had missed something really major…
Thinking back, I probably should have said ‘full duplex’, rather than ‘bi-directional’. The Q2686 SPI API only seems to support half-duplex communications. This is a major hick-up in the Wavecom SPI API.
Writing all zeros out the MOSI pin to clock data in seems to be a sane thing to do. It’s been so long since I’ve worked on that section of my code that I can’t remember what I saw on the oscilloscope.
I meant another thing. When data is being read by q2686 it has a meaningful data on input, but what does it have on output?
Is it a default behaviour for all SPI slaves? I tried to tie chip select to ground and have not seen any differences. What is chip select behaviour from q2686 side?
I managed to transfer and print a pretty large amount of data in blocks of 0x1000 bytes for every transfer. It seems that block size is limited only by the receive buffer which is limited by task stack size. But still there is some lack of synchronization in opcode-address-data protocol - on 9th transfer I’ve got a buffer filled with a single symbol and needed to reset SPI slave state.
I know that it is master and it is active low by default. I want to know is it active during all read sequence or is it active during each byte and inactive between them.
if you’e only got one device on your spi-bus, and the device is not likely to be removed from the bus you can leave the subscription active for as long as your wcpu remains active.
(that’s the way i’m using the two spi-busses on my q2686)