xxxajk / spi4teensy3

Faster SPI library optimized for the teensy 3.0 from pjrc.com
GNU General Public License v3.0
90 stars 25 forks source link

Not for Teensy 3.6 #10

Open regenesis-art opened 7 years ago

regenesis-art commented 7 years ago

The code won't include itself because the Teensy 3.6 define MK66FX1M0 which is not among the cores the library works for. Additionally, simply adding that constant to the #ifs is not enough - the library is not reliable on the Teensy 3.6 either, probably due to the faster CPU.

xxxajk commented 7 years ago

If you are using this for the UHS library, this is an already known fact, and you should be using UHS30. If you are using this in some other project, let me know and I will fix it. Yes I have Teensy 3.6's here.

Either way, please let me know.

jscatena88 commented 7 years ago

I would be interested in getting this working with the teensy 3.6. I am attempting to use this library to communicate with the invensense ICS-52000 microphone which uses an SPI like TDM protocol. It requires the ability to send a continuous clock signal while receiving data at 24 MHz

xxxajk commented 7 years ago

I'll have to check if SPI can actually do 24MHZ. It will depend on what clock SPI runs from, and if it is a 24MHz clock, that may or may not be a reliable solution. If there is a higher rate clock and SPI can use that rate, without altering any of the clocks, then it could be doable...

xxxajk commented 7 years ago

Looks like it takes clocking from the BUS clock on Teensy 3.[0|1|2]. Also seems to be the case for the 3.[5|6] according to the datasheet.

xxxajk commented 7 years ago

Looking into the datasheet, currently, the K66 seems to have a few minor differences. For example, K66 can do a full 32bit frame size, K20 is limited to 16bit... I'll play with this stuff tonight, and make this work as-is for Teensy 3.5 and 3.6. Shouldn't be difficult to do, and probabbly only requires a few CPP `

if defined(whatever)

stuff here

else

other stuff here

endif

`

type stuff...

xxxajk commented 7 years ago

Without messing about with F_BUS, this is what you get... https://github.com/xxxajk/spi4teensy3/blob/master/spi4teensy3.cpp#L23

So it appears that 12MHz is the maximum, which is unfortunate, however understandable because of how it detects the clocks. The hardware pretty much requires a 1/2 clock to be reliable, and sample data at the mid-point of the clock. I do not (at this point) see any way to select a different/faster clock source. for 24MHz SPI, you would need to have a 48MHz clock for SPI, and some very well done signal routing. Not sure if passing such a fast signal on pins would work out well. The signal paths would need to be very short. Any propagation delays, signal reflections, and noise will be problematic as well.

xxxajk commented 7 years ago

Now supports Teensy 3.5 and 3.6, please test and confirm.

jscatena88 commented 7 years ago

I downloaded the new code and can confirm that it successfully compiles and runs on the Teensy 3.6. I have only so far compiled and hooked up an oscilloscope to the clock to make sure it was outputting as expected. I will most likely be able to test actual communication with our microphones later today

xxxajk commented 7 years ago

Excellent news. I have already verified that it does work with the USB Host Shield (MAX3421E) so you should find similar results.