Need SPI ADC part advice, and 4xSPI questions

Status
Not open for further replies.

kdharbert

Well-known member
I'm working on a design that requires each communication pin to be either input or output. This means I2C is not an option since SDA is bidirectional. All the accelerometers I've been working with have required I2C, so I need to search for new units with good library support that utilize hardware SPI channels. Any good recommendations?

[Bonus] I need to make readings from several ADCs simultaneously. I've heard of people implementing 4x SPI with their Teensys. If this is doable, I'd like to be able to take 4 ADCs with duplicate input pins from the Teensy and then clock out four channels of data in parallel. Does this sound possible?
 
Warning I have not used many of the accelerometers, although I do have a few of them sitting around here somewhere... My desk and office areas organization is not as it should be.

But for example Adafruit and Sparkfun sell different units that can run using SPI like:
https://www.adafruit.com/product/4097 (ADXL343
https://www.sparkfun.com/products/14686 (BNO080) - I have few around and these also support output to a UART... Is that an option?
...

Now running multiples of these?

Now running 4 SPI? We only have 3 SPI ports and on T4.1, SPI2 is either using SD card pins which are harder to get to. Or using the same pins that are setup to have Memory chips installed... So you can do one or the other...

You can setup code to read from all three SPI ports at the same time, so you could setup to do three that way...

I was also playing around with FlexIO at one point and working on an SPI port, I think it may have DMA support, but has been awhile since I looked at it and don't remember how well it worked.
Again no promises. but it is up at: https://github.com/KurtE/FlexIO_t4
 
UART I\O IS an option. What's available?
Both the units you listed require I2C. The ADCL343 clearly shows I2C. The BNO080 requires it to setup the SPI:)

I had the idea of setting up an interrupt on the SPI clock so that I can read three extra MISO pins when the hardware SPI reads only one.
I think I've tried to do that, but hardware SPI hijacks the CLK pin interrupt. I'm not sure I can do the interrupt any other way except for wiring the clock pin to another pin to use as the interrupt and then reading the three extra pins. Not too much harder, but does cost an extra pin.
 
Could you clarify the 4x SPI bit? are you talking 4 seperate SPI ports -OR- were you thinking about an SPI port with 4 data lanes?
 
Perhaps looking at how the on board SD Card operates on T3.5 & T3.6 could shed some light on what is required to implement that.
 
I think that, in theory, on teensy 4.1 both the QSPI port (used for the extra PSRAM normally) and FlexIO port(s) could be set up for generic 4-lane SPI ("quad-SPI" or something). Considering that I read somewhere about a project that somehow managed to arrange non-continuous FlexIO pins to handle 12 (or was it 13) lanes (correcting the bits to correct places in software) :p

I also took a quick look at the SDCard port, but its controller seemed to be too specialized, expecting all kinds of standard specific responses etc. (At least on Teensy 4.1).

The QSPI-idea is just something I have been reading on the datasheet, not seeing yet anything that would outright prevent its "generic" use, though it would need somewhat non-standard configuration; e.g. no address commands/instructions, just directly with read data commands, and immediate "stop" command after that. Definitely would need some deep dive in the manual. Though I've been hit with tiny sub-notes too many times before on various serial protocol implementations and I'm thus about 99% that such a specific port (meant mostly for memories) must have some kind of gotcha still waiting to surprise...
 
UART I\O IS an option. What's available?
Both the units you listed require I2C. The ADCL343 clearly shows I2C.
The documents and libraries show the ability to hook up to SPI.
Example: https://forum.arduino.cc/t/adxl345-wiring-issue-on-spi/257756
Or page 15 of their PDF: https://www.analog.com/media/en/technical-documentation/data-sheets/ADXL345.pdf

The BNO080 requires it to setup the SPI:)
Another version of the BNO is the BNO085: https://www.adafruit.com/product/4754
Again it can be I2C, Uart, or SPI. This is chosen by solder jumpers on the back of the unit.

I had the idea of setting up an interrupt on the SPI clock so that I can read three extra MISO pins when the hardware SPI reads only one.
I think I've tried to do that, but hardware SPI hijacks the CLK pin interrupt. I'm not sure I can do the interrupt any other way except for wiring the clock pin to another pin to use as the interrupt and then reading the three extra pins. Not too much harder, but does cost an extra pin.
Some reason I have doubts about this working... But can always be proved wrong.

But before I went down that rabbit hole, (and I have gone down many), I might start asking myself some simple questions.

Things like:

A list of sensors that you are trying to decide between?
What sample rate are you needing/expecting?
Does going to higher sample rate, actually give me any more real data? For example with ADXL345 (since I still have PDF open),
I see you can configure it for example from that PDF:
Use of the 3200 Hz and 1600 Hz output data rates is only recommended with SPI communication rates greater than or equal to 2 MHz. The 800 Hz output data rate is recommended only for communication speeds greater than or equal to 400 kHz, and the remaining data rates scale proportionally. For example, the minimum recommended communication speed for a 200 Hz output data rate is 100 kHz.

So for example if 800hz is sufficient and you can configure the SPI transfer speed to 5mhz (I think max) how much time does this take up on the SPI buss?
 
Status
Not open for further replies.
Back
Top