FlexIOSPI with DQS

JoCaGoVi

Member
I'm developing on a Teensy 4.1 with Platform IO and Visual Studio Code on Windows 11

I do have a specific need that I saw the 1060 chip could address

I need to run SPI on a level shifter to 1.8 and for other projects to 1.2V.
Adding level shifters add delay to the lines. This would affect MISO line more dramatically.

If I'm able to use the DQS feature from the 1060 as documented on
DQS.png

This should allow for arbitrary delays

I do not have the experience, (as I started today on embedded coding, before C#, perl, python) It seems knowledge of the internals of the 1060 IC is required.

Is this already supported in Teensy Arduino?

Thank you

-Jose
 
Last edited:
Before answering directly, please let me address a couple possible misunderstandings first.

The 1060 chip has 2 different types of SPI ports, called LPSPI and FlexSPI. They are completely different hardware. LPSPI is similar to normal SPI on other microcontrollers. It's supported by the SPI library. The 1060 chip has 4 LPSPI ports, 3 of which can be accessed on the Teensy 4.1 pins.

FlexSPI is meant for memory chips. The 1062 chip has 2 FlexSPI ports. The main one is used for the flash memory which holds your program. The 2nd FlexSPI port connects to 2 sets of pads on the bottom side of Teensy 4.1, which are meant for PSRAM or more flash memory. While it's theoretically possible to use FlexSPI for non-memory chips, this is rarely done. The main obstacle is FlexSPI only supports very fast clock speeds, which many ordinary SPI chips can't handle. Connecting other chips to those bottom side pads is also pretty inconvenient.

The DQS pad is a FlexSPI feature. It doesn't exist for LPSPI. Those pins also are not routed on Teensy 4.1, so you can't really use DQS without making a custom board (as was done recently for SDRAM, where a 10pF capacitor on DQS was found to allow higher overclock speeds).

If you want to experiment with DQS, for the FlexSPI2 you'll need to access it at the GPIO_SD_B0_05 pad (see page 300 in the reference manual) which is connected to the SD card socket. The only other place to access DQS is GPIO_EMC_11, which isn't routed on Teensy 4.1. But if you were to make a custom PCB using the T4 bootloader chip (as was done for SDRAM), that would be your other option.

Now to directly answer your question "Is this already supported in Teensy Arduino?", the best answer is "not really". For FlexSPI2 the only parts we directly support are the PSRAM chip and flash memory chips supported by the LittleFS library. Those are all 3V parts. None use the DQS pin. So if you want to try making use of DQS, you'll need to dive into the low level details. Hopefully the info in this message at least gets you off to a good start and can set your expectations about the challenges and limitations you'll face.
 
Thank you for the quick reply,

My device (not PSRAM, SDRAM or any off-the-shelf really) its a custom device intended for embedded systems, that I can't share any details on.

The Interface is 1.2V for silicon and 1.8V on emulation and has the following pins
SCLK up to 50MHz
MISO
MOSI
CS
IRQ

I'm trying to implement IRQ handling and USB(COM port) to SPI bridging on Teensy 4.1

We looked at FTDI but it only supports 40MHz and it has a lot of dead time on CS to CLK and CLK to CS and all of the IRQ smarts went to the host PC which is slow.

I want to handle the IRQ at the MCU (the code is not that big) should not be a problem

The only problem left over is level shifter delays.

The level translation at SCK frequencies > 16MHz for level translation is problematic at best. Asking level shifter vendors to bin the fastest parts has really low yields.

If I can get a sample clock for MISO (basically return the SCLK with all the delays that MISO has) then the delay becomes irrelevant

Thank you in advance for any insights you may have

-Jose
 
I'm afraid not, I dont have any influence in the design.
I was tasked with Test support outside the embedded system.

Another approach I was thinking was to use two SPI, one master one slave so to receive Masters MISO on the slave as MOSI:
I saw this example in a Texas Instrument document: "Extending the SPI bus for long-distance communication"

1745714026861.png


Does FlexIOSPI support Slave mode?
 
Last edited:
Don’t confuse FlexSPI with FlexIO, which the latter is a module that can emulate several protocols and has an SPI emulation library available by @KurtE

You might be able to emulate some form of 4-bit SPI with the FlexIO module, but it won’t support simultaneous writes and reads, can only do one operation on the bus as a time.

As @Paul mentioned, if you need FlexSPI and DQS, then you need access to pins that are not currently routed - while off the shelf Teensies won’t help, there are open source projects such as the SDRAM board that you can download, edit and expose the necessary pins needed for proper hardware support. Will be pricey, but it might fit into your project budget
 
Thank you for your input @Rezo.
I did see FlexIOSPI I'm actally using that as an exercise. FlexSPI 1bit SDR with DQS would be a silver bullet. Im just wondering if there are any examples or libraries already available. Learning the 1062 lower decks is not a simple endevour. Mostly coming from HLLs. I only done some assembly on the Parallax SX48 long time ago.

Creating a new board is not prohibited but I need to justify it with a plan. Learning an MCU from scratch, that is hard, but I'm not afraid of it neither I just dont know where to start.

-Jose
 
I just noticed my error in the title

MCUs FLEXSPI not FLEXIOSPI with DQS.

Im using FLEXIOSPI Master now as a way to learn the PlatformIO IDE. If FLEXIOSPI also supports slave mode that is another was to do it as shown on the figure above
 
Now I'm confused. Is Teensy supposed to be the SPI master (transmits SCLK and CS) or the SPI slave (receives SCLK and CS)?

I'm pretty sure FlexSPI (chapter 27 in the reference manual) can only work in master mode.

As @Paul mentioned, if you need FlexSPI and DQS, then you need access to pins that are not currently routed

GPIO_EMC_11 isn't routed. But the info in the reference manual seems to say GPIO_SD_B0_05 could alternately be used. It is routed on Teensy 4.1 to the build in SD socket. Not very convenient, but also not the impossible situation of an unrouted BGA pin.
 
For the diagram the idea seems to be using two LPSPI interfaces with one in master mode and the other in slave mode using the voltage-converted/delayed clock signal.
The question is how fast are these SPI devices going to be driven? Given the low limit of LPSPI, I don't believe the delays caused by the voltage shifters are going to have any significance.
 
My apologies, I was a bit confused myself, but here is my attempt to clarify

My Device interface is the Slave SPI 1 bit SDR at 50MHz max.
Code:
CLK  //max 50MHz
SIMO //I'll keep using this names to indicate a slave
SOMI //I'll keep using this names to indicate a slave
CS   //active low
IRQ  //active high

The FLEXSPI from the NXP RT1062 allows to use the DQS:
My drawing of how I think it would work
FLEXSPI.png

DQS as a clock to sample MISO (from SOMI), this has the benefit of compensation for any propagation delays introduced in the data link (as in by level shifters).

Does FLEXSPI support 1bit as in MISO/MOSI?

As an alternative using two FLEXIOSPI one master and one slave:
FLEXIOSPI.png


Am I understanding correctly that FLEXIOSPI uses LPSPI with a max of 30MHz?
 
Does FLEXSPI support 1bit as in MISO/MOSI?

Yes.

FlexSPI programming is complicated. You need to write instructions in the LUT memory. Look for "MODE1_SDR" in chapter 27.


Am I understanding correctly that FLEXIOSPI uses LPSPI with a max of 30MHz?

Maybe you're misunderstanding that FlexIO and LPSPI are completely different peripherals.

FlexIO is supported by the FlexIO_t4 library. It's documented in chapter 50 of the reference manual. FlexIO is a collection of shift registers and timers and special logic which can emulate a variety of serial protocols, including SPI.

LPSPI is supported by the SPI library. It's documented in chapter 48.

I'm mentioning the reference manual chapters because the Arduino libraries only support a subset of the full hardware capability. To use more, you will need to deep dive into the reference manual documentation.
 
Thank you so much for all the info. Ill try the already available drives and read more on the reference manual.

Ill update on anything new I come up with

Once again thank you very much.
 
Back
Top