Teensy 4.0 Released

Hi folks. Looks like PJRC releases a new Teensy and it promises to be a screamer.

https://www.pjrc.com/store/teensy40.html

I already ordered a couple and will report back on SmartMatrix compatibility

Cheers,

-Vince

1 Like

Thank you, I was going to ask the same thing :slight_smile:
It should do 128x128 without sweating now, and likely 128x256 except for the size limit in smartmatrix that could probably be removed without too many problem hopefully (well, maybe not since 256 may be one too many to fit in a byte if it’s not 0 based)

I haven’t looked at Teensy 4.0 beyond the specs page. I’m not sure how much work it would take to port SmartMatrix Library, or if it’s pin compatible with the SmartLED Shield. As of now I don’t have any plans to support Teensy 4.0, though it does look like a powerful micro and has a great price and form factor.

If anyone wants to dig into data sheets and reference manuals and help convince me to support the new Teensy, that would be great. I’d want to know if the GPIO ports that are used for the RGB and CLK pins are on the same pins on 4.0 as they are on 3.2. I hope the timer and DMA peripherals operate similar to 3.2, as SmartMatrix Library depends on a very specific implementation

I wonder if with the additional RAM, if the panel can be refreshed a frame at a time like the ESP32 instead of a row at a time.

Even if it’s relatively simple to add support, i have other priorities right now, so please don’t expect Teensy 4.0 support soon.

There are no schemes available yet, but I don’t think there is any problem so that 7 ports are available in contiguous addresses to be able to use DMA with RGB0, RGB1 and Clock. It would take another 4 or 5 ports, also with contiguous addresses for the binary line counter ABDC (E).

I am trying to port the library, but for the RT1020, with a more complex design that offer Teensy 4.0, since I want to use an external RAM of 256Mbit, to run the program from RAM and also have a lot of extra space for work arrays.

However, I have already ordered two units of Teensy 4.0, to start testing it with Teensyduino. If all interrupt management, DMA and SPI is similar, I think there should be no problem, in being able to use it with few changes, we just need to know the actual allocation of the available ports.

Louis I think it is worth the effort to port Smartmatrix to the RT series of NXP, the improvement in process power is spectacular, a Cortex M7 at 600Mhz, is impressive. We could make much larger LED panels, with better refresh rates and color depth, much better than anything designed based on the ESP32.

1 Like

In addition to trying to port the library to compile with MCUXpresso, I am trying to compile from the Arduino - Teensyduino 1.47 Beta environment.

The first compilation errors, not related to the Smartmatrix, are from the SdFAT library to handle SD cards with FAT volumes.

And the first compilation errors, on the Smartmatrix, refer to F_BUS and the definition of timers. For F_BUS, F_BUS_ACTUAL is defined in Teensy 4.0, but I’m not yet sure if it’s the same. As for timers, it is defined completely differently, I am waiting to get documentation about it, also about DMA and the pinout of the board, to know what ports are being used.

2 Likes

found the same issue with F BUS. this is way above my pay grade.

I see that FASTled has been updated to version 3.3. to support teensy 4.0

The brains over at FASTled shared some info about parallel output on the teensy 4.0, i hope it helps.

Parallel output on the Teensy 4

The new Teensy 4 also supports parallel output, but it’s done slightly differently from the above platforms. First off, there are three sets of possible pins that can be used - each of the three set of pins, in order:

  • First: 1,0,24,25,19,18,14,15,17,16,22,23,20,21,26,27
  • Second: 10,12,11,13,6,9,32,8,7
  • Third: 37, 36, 35, 34, 39, 38, 28, 31, 30

Note that any pin above 21 is a pad on the back of the board. This is the ordering of pins for each grouping. Now, when calling add LEDs, you can pick which pin you want to start with in each group, and how many lanes. For example, if you want 16 way output, you would use Pin 1 (and the rest of the pins in that first group) (with 4 of the strips having to connect to the backside of the panel). If you only want a few channels of output, say 6 - and you don’t want to use pads on the back, then you can select pin 19 as your initial pin (from that first group), and set the number of channels to 8 which will use pins 19,18,14,15,17,16.

Again, for the Teensy 4 - you select the first pin that you want for output, and then the number of pins after that in the list from above.

Then in code, you use addLeds like this:

#define NUM_LEDS_PER_STRIP 60
#define NUM_STRIPS 6

CRGB leds[NUM_LEDS_PER_STRIP * NUM_STRIPS];

void setup() {
    FastLED.addLeds<NUM_STRIPS, WS2812, 19, GRB>(leds, NUM_LEDS_PER_STRIP);
}

and you have parallel output! Also note that on the Teensy4 - you specify which clockless chipset you want to use (no more being limited to which chipsets I’ve defined CHIPSET_PORTX for…) - if this mechanism seems to continue to work well, I may make it available on the other platforms as well, but for now I didn’t want to make changes outside of the teensy4.

Thanks for your information lemuroide.

However, where I find the difficulty, for now, it is in the configuration and programming of the DMA and timers for the new Teensy 4.0, there is practically no information, and the example sources of the new Teensyduino Beta 1.47, does not offer any examples.

I am considering portability to MCUXpresso, until PJRC provides more information, board schematics and some examples or documentation to use DMA and timers. The rest of the sources, I don’t think I have difficulty port it using the Arduino IDE with the Teensyduino plugin.

Regards

1 Like

Well, it seems that the real ports of the RT1062, in Teensy 4.0, are identified on the board pins. Now I need to get more information about DMA and timers.

On my custom board with RT1020, I used the AD_B1_xx ports that are also on the Teensy 4.0 pins (14 to 23). There, the RGB0, RGB1 and clock signals of Smartmatrix could be connected for use with DMA.

I think that as soon as I get the information to configure and use the timers and the DMA with Teensy 4.0, the portability of Smartmatrix is not as complicated as it may seem.


1 Like

One of us (me) is way over his head with this stuff. So, go team!!! I’ll bring the beer.

I tried to build for the teensy 4.0 I just received, and here is the output

In file included from /home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrix3.h:127:0,
                 from /home/merlin/Arduino/libraries/SmartMatrix/src/SmartLEDShieldV4.h:5,
                 from /home/merlin/arduino/libraries/SmartMatrix/examples/FeatureDemo/FeatureDemo.ino:6:
/home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrixMultiplexedRefreshTeensy_Impl.h: In constructor 'SmartMatrix3RefreshMultiplexed<refreshDepth, matrixWidth, matrixHeight, panelType, optionFlags>::SmartMatrix3RefreshMultiplexed(uint8_t, SmartMatrix3RefreshMultiplexed<refreshDepth, matrixWidth, matrixHeight, panelType, optionFlags>::rowDataStruct*)':
/home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrixMultiplexedRefreshTeensy_Impl.h:38:40: error: 'TIMER_FREQUENCY' was not declared in this scope
 #define NS_TO_TICKS(X)      (uint32_t)(TIMER_FREQUENCY * ((X) / 1000000000.0))
                                        ^
/home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrixMultiplexedRefreshTeensy_Impl.h:50:32: note: in expansion of macro 'NS_TO_TICKS'
 #define MIN_BLOCK_PERIOD_TICKS NS_TO_TICKS(MIN_BLOCK_PERIOD_NS)
                                ^
/home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrixMultiplexedRefreshTeensy_Impl.h:139:34: note: in expansion of macro 'MIN_BLOCK_PERIOD_TICKS'
     timerPairIdle.timer_period = MIN_BLOCK_PERIOD_TICKS;
                                  ^
/home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrixMultiplexedRefreshTeensy_Impl.h: In static member function 'static void SmartMatrix3RefreshMultiplexed<refreshDepth, matrixWidth, matrixHeight, panelType, optionFlags>::calculateTimerLUT()':
/home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrixMultiplexedRefreshTeensy_Impl.h:47:26: error: 'TIMER_FREQUENCY' was not declared in this scope
 #define TICKS_PER_ROW   (TIMER_FREQUENCY/refreshRate/MATRIX_SCAN_MOD)
                          ^
/home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrixMultiplexedRefreshTeensy_Impl.h:48:36: note: in expansion of macro 'TICKS_PER_ROW'
 #define IDEAL_MSB_BLOCK_TICKS     (TICKS_PER_ROW/2)
                                    ^
/home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrixMultiplexedRefreshTeensy_Impl.h:233:30: note: in expansion of macro 'IDEAL_MSB_BLOCK_TICKS'
     uint16_t msbBlockTicks = IDEAL_MSB_BLOCK_TICKS + MSB_BLOCK_TICKS_ADJUSTMENT_INCREMENT;
                              ^
/home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrixMultiplexedRefreshTeensy_Impl.h: In static member function 'static void SmartMatrix3RefreshMultiplexed<refreshDepth, matrixWidth, matrixHeight, panelType, optionFlags>::setRefreshRate(uint8_t)':
/home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrixMultiplexedRefreshTeensy_Impl.h:53:32: error: 'TIMER_FREQUENCY' was not declared in this scope
 #define MIN_REFRESH_RATE    (((TIMER_FREQUENCY/65535)/MATRIX_SCAN_MOD/2) + 1)
                                ^
/home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrixMultiplexedRefreshTeensy_Impl.h:291:25: note: in expansion of macro 'MIN_REFRESH_RATE'
     if(newRefreshRate > MIN_REFRESH_RATE)
                         ^
In file included from /home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrix3.h:128:0,
                 from /home/merlin/Arduino/libraries/SmartMatrix/src/SmartLEDShieldV4.h:5,
                 from /home/merlin/arduino/libraries/SmartMatrix/examples/FeatureDemo/FeatureDemo.ino:6:
/home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrixAPA102RefreshTeensy_Impl.h: In static member function 'static void SmartMatrixAPA102Refresh<refreshDepth, matrixWidth, matrixHeight, panelType, optionFlags>::begin()':
/home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrixAPA102RefreshTeensy_Impl.h:165:55: error: 'SPI0_PUSHR' was not declared in this scope
     dmaClockOutDataApa.destination((volatile uint8_t&)SPI0_PUSHR);
                                                       ^
/home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrixAPA102RefreshTeensy_Impl.h:167:47: error: 'DMAMUX_SOURCE_SPI0_TX' was not declared in this scope
     dmaClockOutDataApa.triggerAtHardwareEvent(DMAMUX_SOURCE_SPI0_TX);
                                               ^
In file included from /var/local/arduino-1.8.9-teensyduino-1.47/hardware/teensy/avr/cores/teensy4/core_pins.h:32:0,
                 from /var/local/arduino-1.8.9-teensyduino-1.47/hardware/teensy/avr/cores/teensy4/wiring.h:38,
                 from /var/local/arduino-1.8.9-teensyduino-1.47/hardware/teensy/avr/cores/teensy4/WProgram.h:45,
                 from /tmp/arduino_build_363732/pch/Arduino.h:6:
/home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrixAPA102RefreshTeensy_Impl.h:170:65: error: 'ROW_CALCULATION_ISR_PRIORITY' was not declared in this scope
     NVIC_SET_PRIORITY(IRQ_DMA_CH0 + dmaClockOutDataApa.channel, ROW_CALCULATION_ISR_PRIORITY);
                                                                 ^
/var/local/arduino-1.8.9-teensyduino-1.47/hardware/teensy/avr/cores/teensy4/imxrt.h:8201:104: note: in definition of macro 'NVIC_SET_PRIORITY'
 #define NVIC_SET_PRIORITY(irqnum, priority)  (*((volatile uint8_t *)0xE000E400 + (irqnum)) = (uint8_t)(priority))
                                                                                                        ^
In file included from /home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrix3.h:128:0,
                 from /home/merlin/Arduino/libraries/SmartMatrix/src/SmartLEDShieldV4.h:5,
                 from /home/merlin/arduino/libraries/SmartMatrix/examples/FeatureDemo/FeatureDemo.ino:6:
/home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrixAPA102RefreshTeensy_Impl.h:173:5: error: 'FTM2_SC' was not declared in this scope
     FTM2_SC = 0;
     ^
/home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrixAPA102RefreshTeensy_Impl.h:174:5: error: 'FTM2_CNT' was not declared in this scope
     FTM2_CNT = 0;
     ^
/home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrixAPA102RefreshTeensy_Impl.h:175:5: error: 'FTM2_MOD' was not declared in this scope
     FTM2_MOD = APA_TICKS_PER_FRAME;
     ^
/home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrixAPA102RefreshTeensy_Impl.h:48:32: error: 'APA_TIMER_FREQUENCY' was not declared in this scope
 #define APA_TICKS_PER_FRAME   (APA_TIMER_FREQUENCY/refreshRate)
                                ^
/home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrixAPA102RefreshTeensy_Impl.h:175:16: note: in expansion of macro 'APA_TICKS_PER_FRAME'
     FTM2_MOD = APA_TICKS_PER_FRAME;
                ^
/home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrixAPA102RefreshTeensy_Impl.h:191:28: warning: there are no arguments to 'FTM_SC_CLKS' that depend on a template parameter, so a declaration of 'FTM_SC_CLKS' must be available [-fpermissive]
     FTM2_SC = FTM_SC_CLKS(1) | FTM_SC_PS(APA_LATCH_TIMER_PRESCALE) | FTM_SC_TOIE;
                            ^
/home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrixAPA102RefreshTeensy_Impl.h:191:66: warning: there are no arguments to 'FTM_SC_PS' that depend on a template parameter, so a declaration of 'FTM_SC_PS' must be available [-fpermissive]
     FTM2_SC = FTM_SC_CLKS(1) | FTM_SC_PS(APA_LATCH_TIMER_PRESCALE) | FTM_SC_TOIE;
                                                                  ^
/home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrixAPA102RefreshTeensy_Impl.h:191:70: error: 'FTM_SC_TOIE' was not declared in this scope
     FTM2_SC = FTM_SC_CLKS(1) | FTM_SC_PS(APA_LATCH_TIMER_PRESCALE) | FTM_SC_TOIE;
                                                                      ^
/home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrixAPA102RefreshTeensy_Impl.h:193:27: error: 'IRQ_FTM2' was not declared in this scope
     attachInterruptVector(IRQ_FTM2, apaRowShiftCompleteISR<refreshDepth, matrixWidth, matrixHeight, panelType, optionFlags>);
                           ^
/home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrixAPA102RefreshTeensy_Impl.h: In function 'void apaRowShiftCompleteISR()':
/home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrixAPA102RefreshTeensy_Impl.h:233:5: error: 'SPI0_RSER' was not declared in this scope
     SPI0_RSER = 0;
     ^
/home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrixAPA102RefreshTeensy_Impl.h:235:5: error: 'SPI0_SR' was not declared in this scope
     SPI0_SR = SPI_SR_TCF | SPI_SR_EOQF | SPI_SR_TFUF | SPI_SR_TFFF | SPI_SR_RFOF | SPI_SR_RFDF;
     ^
/home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrixAPA102RefreshTeensy_Impl.h:235:15: error: 'SPI_SR_TCF' was not declared in this scope
     SPI0_SR = SPI_SR_TCF | SPI_SR_EOQF | SPI_SR_TFUF | SPI_SR_TFFF | SPI_SR_RFOF | SPI_SR_RFDF;
               ^
/home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrixAPA102RefreshTeensy_Impl.h:235:28: error: 'SPI_SR_EOQF' was not declared in this scope
     SPI0_SR = SPI_SR_TCF | SPI_SR_EOQF | SPI_SR_TFUF | SPI_SR_TFFF | SPI_SR_RFOF | SPI_SR_RFDF;
                            ^
/home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrixAPA102RefreshTeensy_Impl.h:235:42: error: 'SPI_SR_TFUF' was not declared in this scope
     SPI0_SR = SPI_SR_TCF | SPI_SR_EOQF | SPI_SR_TFUF | SPI_SR_TFFF | SPI_SR_RFOF | SPI_SR_RFDF;
                                          ^
/home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrixAPA102RefreshTeensy_Impl.h:235:56: error: 'SPI_SR_TFFF' was not declared in this scope
     SPI0_SR = SPI_SR_TCF | SPI_SR_EOQF | SPI_SR_TFUF | SPI_SR_TFFF | SPI_SR_RFOF | SPI_SR_RFDF;
                                                        ^
/home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrixAPA102RefreshTeensy_Impl.h:235:70: error: 'SPI_SR_RFOF' was not declared in this scope
     SPI0_SR = SPI_SR_TCF | SPI_SR_EOQF | SPI_SR_TFUF | SPI_SR_TFFF | SPI_SR_RFOF | SPI_SR_RFDF;
                                                                      ^
/home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrixAPA102RefreshTeensy_Impl.h:235:84: error: 'SPI_SR_RFDF' was not declared in this scope
     SPI0_SR = SPI_SR_TCF | SPI_SR_EOQF | SPI_SR_TFUF | SPI_SR_TFFF | SPI_SR_RFOF | SPI_SR_RFDF;
                                                                                    ^
/home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrixAPA102RefreshTeensy_Impl.h:239:17: error: 'SPI_RSER_TFFF_RE' was not declared in this scope
     SPI0_RSER = SPI_RSER_TFFF_RE | SPI_RSER_TFFF_DIRS;
                 ^
/home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrixAPA102RefreshTeensy_Impl.h:239:36: error: 'SPI_RSER_TFFF_DIRS' was not declared in this scope
     SPI0_RSER = SPI_RSER_TFFF_RE | SPI_RSER_TFFF_DIRS;
                                    ^
/home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrixAPA102RefreshTeensy_Impl.h:244:5: error: 'FTM2_SC' was not declared in this scope
     FTM2_SC &= ~FTM_SC_TOF;
     ^
/home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrixAPA102RefreshTeensy_Impl.h:244:17: error: 'FTM_SC_TOF' was not declared in this scope
     FTM2_SC &= ~FTM_SC_TOF;
                 ^
In file included from /home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrix3.h:127:0,
                 from /home/merlin/Arduino/libraries/SmartMatrix/src/SmartLEDShieldV4.h:5,
                 from /home/merlin/arduino/libraries/SmartMatrix/examples/FeatureDemo/FeatureDemo.ino:6:
/home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrixMultiplexedCalcTeensy_Impl.h: In static member function 'static void SmartMatrix3<refreshDepth, matrixWidth, matrixHeight, panelType, optionFlags>::matrixCalculations(bool)':
/home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrixMultiplexedRefreshTeensy_Impl.h:53:32: error: 'TIMER_FREQUENCY' was not declared in this scope
 #define MIN_REFRESH_RATE    (((TIMER_FREQUENCY/65535)/MATRIX_SCAN_MOD/2) + 1)
                                ^
/home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrixMultiplexedCalcTeensy_Impl.h:111:47: note: in expansion of macro 'MIN_REFRESH_RATE'
             if(!initial && calc_refreshRate > MIN_REFRESH_RATE) {
                                               ^
/home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrixMultiplexedRefreshTeensy_Impl.h:53:32: error: 'TIMER_FREQUENCY' was not declared in this scope
 #define MIN_REFRESH_RATE    (((TIMER_FREQUENCY/65535)/MATRIX_SCAN_MOD/2) + 1)
                                ^
/home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrixMultiplexedCalcTeensy_Impl.h:160:35: note: in expansion of macro 'MIN_REFRESH_RATE'
             if(calc_refreshRate > MIN_REFRESH_RATE) {
                                   ^
/home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrixMultiplexedCalcTeensy_Impl.h: In member function 'void SmartMatrix3<refreshDepth, matrixWidth, matrixHeight, panelType, optionFlags>::setRefreshRate(uint8_t)':
/home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrixMultiplexedRefreshTeensy_Impl.h:53:32: error: 'TIMER_FREQUENCY' was not declared in this scope
 #define MIN_REFRESH_RATE    (((TIMER_FREQUENCY/65535)/MATRIX_SCAN_MOD/2) + 1)
                                ^
/home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrixMultiplexedCalcTeensy_Impl.h:216:25: note: in expansion of macro 'MIN_REFRESH_RATE'
     if(newRefreshRate > MIN_REFRESH_RATE)
                         ^
In file included from /home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrix3.h:140:0,
                 from /home/merlin/Arduino/libraries/SmartMatrix/src/SmartLEDShieldV4.h:5,
                 from /home/merlin/arduino/libraries/SmartMatrix/examples/FeatureDemo/FeatureDemo.ino:6:
/home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrixCoprocessorSend_Impl.h: In static member function 'static void SmartMatrix3CoprocessorSend<refreshDepth, matrixWidth, matrixHeight, panelType, optionFlags>::setRefreshRate(uint8_t)':
/home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrixCoprocessorSend_Impl.h:40:41: error: 'TIMER_FREQUENCY' was not declared in this scope
 #define COPROCESSOR_MIN_REFRESH_RATE (((TIMER_FREQUENCY/65535)/MATRIX_SCAN_MOD) + 1)
                                         ^
/home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrixCoprocessorSend_Impl.h:139:25: note: in expansion of macro 'COPROCESSOR_MIN_REFRESH_RATE'
     if(newRefreshRate > COPROCESSOR_MIN_REFRESH_RATE)
                         ^
In file included from /home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrix3.h:140:0,
                 from /home/merlin/Arduino/libraries/SmartMatrix/src/SmartLEDShieldV4.h:5,
                 from /home/merlin/arduino/libraries/SmartMatrix/examples/FeatureDemo/FeatureDemo.ino:6:
/home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrixCoprocessorSend_Impl.h: In static member function 'static void SmartMatrix3CoprocessorSend<refreshDepth, matrixWidth, matrixHeight, panelType, optionFlags>::begin()':
/home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrixCoprocessorSend_Impl.h:170:67: error: 'SPI0_PUSHR' was not declared in this scope
     dmaClockOutDataCoprocessorSend.destination((volatile uint8_t&)SPI0_PUSHR);
                                                                   ^
/home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrixCoprocessorSend_Impl.h:172:59: error: 'DMAMUX_SOURCE_SPI0_TX' was not declared in this scope
     dmaClockOutDataCoprocessorSend.triggerAtHardwareEvent(DMAMUX_SOURCE_SPI0_TX);
                                                           ^
/home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrixCoprocessorSend_Impl.h:178:5: error: 'FTM2_SC' was not declared in this scope
     FTM2_SC = 0;
     ^
/home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrixCoprocessorSend_Impl.h:179:5: error: 'FTM2_CNT' was not declared in this scope
     FTM2_CNT = 0;
     ^
/home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrixCoprocessorSend_Impl.h:180:5: error: 'FTM2_MOD' was not declared in this scope
     FTM2_MOD = COPROCESSOR_TICKS_PER_ROW;
     ^
In file included from /home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrix3.h:140:0,
                 from /home/merlin/Arduino/libraries/SmartMatrix/src/SmartLEDShieldV4.h:5,
                 from /home/merlin/arduino/libraries/SmartMatrix/examples/FeatureDemo/FeatureDemo.ino:6:
/home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrixCoprocessorSend_Impl.h:35:42: error: 'F_BUS' was not declared in this scope
 #define COPROCESSOR_TIMER_FREQUENCY     (F_BUS/16)
                                          ^
/home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrixCoprocessorSend_Impl.h:38:38: note: in expansion of macro 'COPROCESSOR_TIMER_FREQUENCY'
 #define COPROCESSOR_TICKS_PER_ROW   (COPROCESSOR_TIMER_FREQUENCY/refreshRate/MATRIX_SCAN_MOD)
                                      ^
/home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrixCoprocessorSend_Impl.h:180:16: note: in expansion of macro 'COPROCESSOR_TICKS_PER_ROW'
     FTM2_MOD = COPROCESSOR_TICKS_PER_ROW;
                ^
In file included from /home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrix3.h:140:0,
                 from /home/merlin/Arduino/libraries/SmartMatrix/src/SmartLEDShieldV4.h:5,
                 from /home/merlin/arduino/libraries/SmartMatrix/examples/FeatureDemo/FeatureDemo.ino:6:
/home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrixCoprocessorSend_Impl.h:184:5: error: 'FTM2_C0V' was not declared in this scope
     FTM2_C0V = 100;
     ^
/home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrixCoprocessorSend_Impl.h:188:43: warning: there are no arguments to 'PORT_PCR_MUX' that depend on a template parameter, so a declaration of 'PORT_PCR_MUX' must be available [-fpermissive]
         CORE_PIN3_CONFIG |= PORT_PCR_MUX(3) | PORT_PCR_DSE | PORT_PCR_SRE;  \
                                           ^
/home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrixCoprocessorSend_Impl.h:192:5: note: in expansion of macro 'ENABLE_LATCH_PWM_OUTPUT'
     ENABLE_LATCH_PWM_OUTPUT();
     ^
/home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrixCoprocessorSend_Impl.h:188:47: error: 'PORT_PCR_DSE' was not declared in this scope
         CORE_PIN3_CONFIG |= PORT_PCR_MUX(3) | PORT_PCR_DSE | PORT_PCR_SRE;  \
                                               ^
/home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrixCoprocessorSend_Impl.h:192:5: note: in expansion of macro 'ENABLE_LATCH_PWM_OUTPUT'
     ENABLE_LATCH_PWM_OUTPUT();
     ^
/home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrixCoprocessorSend_Impl.h:188:62: error: 'PORT_PCR_SRE' was not declared in this scope
         CORE_PIN3_CONFIG |= PORT_PCR_MUX(3) | PORT_PCR_DSE | PORT_PCR_SRE;  \
                                                              ^
/home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrixCoprocessorSend_Impl.h:192:5: note: in expansion of macro 'ENABLE_LATCH_PWM_OUTPUT'
     ENABLE_LATCH_PWM_OUTPUT();
     ^
/home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrixCoprocessorSend_Impl.h:196:28: warning: there are no arguments to 'FTM_SC_CLKS' that depend on a template parameter, so a declaration of 'FTM_SC_CLKS' must be available [-fpermissive]
     FTM2_SC = FTM_SC_CLKS(1) | FTM_SC_PS(COPROCESSOR_LATCH_TIMER_PRESCALE) | FTM_SC_TOIE;
                            ^
/home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrixCoprocessorSend_Impl.h:196:74: warning: there are no arguments to 'FTM_SC_PS' that depend on a template parameter, so a declaration of 'FTM_SC_PS' must be available [-fpermissive]
     FTM2_SC = FTM_SC_CLKS(1) | FTM_SC_PS(COPROCESSOR_LATCH_TIMER_PRESCALE) | FTM_SC_TOIE;
                                                                          ^
/home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrixCoprocessorSend_Impl.h:196:78: error: 'FTM_SC_TOIE' was not declared in this scope
     FTM2_SC = FTM_SC_CLKS(1) | FTM_SC_PS(COPROCESSOR_LATCH_TIMER_PRESCALE) | FTM_SC_TOIE;
                                                                              ^
/home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrixCoprocessorSend_Impl.h:198:27: error: 'IRQ_FTM2' was not declared in this scope
     attachInterruptVector(IRQ_FTM2, coprocessorSendRowShiftCompleteISR<refreshDepth, matrixWidth, matrixHeight, panelType, optionFlags>);
                           ^
/home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrixCoprocessorSend_Impl.h: In function 'void coprocessorSendRowShiftCompleteISR()':
/home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrixCoprocessorSend_Impl.h:240:5: error: 'SPI0_RSER' was not declared in this scope
     SPI0_RSER = 0;
     ^
/home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrixCoprocessorSend_Impl.h:242:5: error: 'SPI0_SR' was not declared in this scope
     SPI0_SR = SPI_SR_TCF | SPI_SR_EOQF | SPI_SR_TFUF | SPI_SR_TFFF | SPI_SR_RFOF | SPI_SR_RFDF;
     ^
/home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrixCoprocessorSend_Impl.h:242:15: error: 'SPI_SR_TCF' was not declared in this scope
     SPI0_SR = SPI_SR_TCF | SPI_SR_EOQF | SPI_SR_TFUF | SPI_SR_TFFF | SPI_SR_RFOF | SPI_SR_RFDF;
               ^
/home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrixCoprocessorSend_Impl.h:242:28: error: 'SPI_SR_EOQF' was not declared in this scope
     SPI0_SR = SPI_SR_TCF | SPI_SR_EOQF | SPI_SR_TFUF | SPI_SR_TFFF | SPI_SR_RFOF | SPI_SR_RFDF;
                            ^
/home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrixCoprocessorSend_Impl.h:242:42: error: 'SPI_SR_TFUF' was not declared in this scope
     SPI0_SR = SPI_SR_TCF | SPI_SR_EOQF | SPI_SR_TFUF | SPI_SR_TFFF | SPI_SR_RFOF | SPI_SR_RFDF;
                                          ^
/home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrixCoprocessorSend_Impl.h:242:56: error: 'SPI_SR_TFFF' was not declared in this scope
     SPI0_SR = SPI_SR_TCF | SPI_SR_EOQF | SPI_SR_TFUF | SPI_SR_TFFF | SPI_SR_RFOF | SPI_SR_RFDF;
                                                        ^
/home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrixCoprocessorSend_Impl.h:242:70: error: 'SPI_SR_RFOF' was not declared in this scope
     SPI0_SR = SPI_SR_TCF | SPI_SR_EOQF | SPI_SR_TFUF | SPI_SR_TFFF | SPI_SR_RFOF | SPI_SR_RFDF;
                                                                      ^
/home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrixCoprocessorSend_Impl.h:242:84: error: 'SPI_SR_RFDF' was not declared in this scope
     SPI0_SR = SPI_SR_TCF | SPI_SR_EOQF | SPI_SR_TFUF | SPI_SR_TFFF | SPI_SR_RFOF | SPI_SR_RFDF;
                                                                                    ^
/home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrixCoprocessorSend_Impl.h:246:17: error: 'SPI_RSER_TFFF_RE' was not declared in this scope
     SPI0_RSER = SPI_RSER_TFFF_RE | SPI_RSER_TFFF_DIRS;
                 ^
/home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrixCoprocessorSend_Impl.h:246:36: error: 'SPI_RSER_TFFF_DIRS' was not declared in this scope
     SPI0_RSER = SPI_RSER_TFFF_RE | SPI_RSER_TFFF_DIRS;
                                    ^
/home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrixCoprocessorSend_Impl.h:252:5: error: 'FTM2_SC' was not declared in this scope
     FTM2_SC &= ~FTM_SC_TOF;
     ^
/home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrixCoprocessorSend_Impl.h:252:17: error: 'FTM_SC_TOF' was not declared in this scope
     FTM2_SC &= ~FTM_SC_TOF;
                 ^
In file included from /home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrix3.h:127:0,
                 from /home/merlin/Arduino/libraries/SmartMatrix/src/SmartLEDShieldV4.h:5,
                 from /home/merlin/arduino/libraries/SmartMatrix/examples/FeatureDemo/FeatureDemo.ino:6:
/home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrixCoprocessorCalc_Impl.h: In static member function 'static void SmartMatrixCoprocessorCalc<refreshDepth, matrixWidth, matrixHeight, panelType, optionFlags>::matrixCalculations(bool)':
/home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrixMultiplexedRefreshTeensy_Impl.h:53:32: error: 'TIMER_FREQUENCY' was not declared in this scope
 #define MIN_REFRESH_RATE    (((TIMER_FREQUENCY/65535)/MATRIX_SCAN_MOD/2) + 1)
                                ^
/home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrixCoprocessorCalc_Impl.h:99:47: note: in expansion of macro 'MIN_REFRESH_RATE'
             if(!initial && calc_refreshRate > MIN_REFRESH_RATE) {
                                               ^
/home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrixMultiplexedRefreshTeensy_Impl.h:53:32: error: 'TIMER_FREQUENCY' was not declared in this scope
 #define MIN_REFRESH_RATE    (((TIMER_FREQUENCY/65535)/MATRIX_SCAN_MOD/2) + 1)
                                ^
/home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrixCoprocessorCalc_Impl.h:148:35: note: in expansion of macro 'MIN_REFRESH_RATE'
             if(calc_refreshRate > MIN_REFRESH_RATE) {
                                   ^
/home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrixCoprocessorCalc_Impl.h: In member function 'void SmartMatrixCoprocessorCalc<refreshDepth, matrixWidth, matrixHeight, panelType, optionFlags>::setRefreshRate(uint8_t)':
/home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrixMultiplexedRefreshTeensy_Impl.h:53:32: error: 'TIMER_FREQUENCY' was not declared in this scope
 #define MIN_REFRESH_RATE    (((TIMER_FREQUENCY/65535)/MATRIX_SCAN_MOD/2) + 1)
                                ^
/home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrixCoprocessorCalc_Impl.h:204:25: note: in expansion of macro 'MIN_REFRESH_RATE'
     if(newRefreshRate > MIN_REFRESH_RATE)
                         ^
/home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrixAPA102Calc_Impl.h: In member function 'void SmartMatrixApaCalc<refreshDepth, matrixWidth, matrixHeight, panelType, optionFlags>::setRefreshRate(uint8_t)':
/home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrixMultiplexedRefreshTeensy_Impl.h:53:32: error: 'TIMER_FREQUENCY' was not declared in this scope
 #define MIN_REFRESH_RATE    (((TIMER_FREQUENCY/65535)/MATRIX_SCAN_MOD/2) + 1)
                                ^
/home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrixAPA102Calc_Impl.h:179:25: note: in expansion of macro 'MIN_REFRESH_RATE'
     if(newRefreshRate > MIN_REFRESH_RATE)
                         ^
In file included from /home/merlin/Arduino/libraries/SmartMatrix/src/Layer_Background.h:117:0,
                 from /home/merlin/Arduino/libraries/SmartMatrix/src/SmartMatrix3.h:48,
                 from /home/merlin/Arduino/libraries/SmartMatrix/src/SmartLEDShieldV4.h:5,
                 from /home/merlin/arduino/libraries/SmartMatrix/examples/FeatureDemo/FeatureDemo.ino:6:
/home/merlin/Arduino/libraries/SmartMatrix/src/Layer_Background_Impl.h: In instantiation of 'void SMLayerBackground<RGB, optionFlags>::drawString(int16_t, int16_t, const RGB&, const char*) [with RGB = rgb24; unsigned int optionFlags = 0u; int16_t = short int]':
/home/merlin/arduino/libraries/SmartMatrix/examples/FeatureDemo/FeatureDemo.ino:704:104:   required from here

Thanks everyone for contributing to this effort. From what I understand so far, this isn’t going to be an easy port, and Teensy 4.0 is very unlikely to be compatible with the SmartLED shield. I’m working on something that will allow driving HUB75 panels from any micro with an SPI port, so indirectly I’m working on Teensy 4.0 support, and that’s my priority for now.

Has Paul ported the OctoWS2812 driver to T4.0? That used a timer and DMA combo similar to SmartMatrix so if that is ported it might be a good reference.

Hello Louis

If you refer to OctoWS2811, I have compiled it for Teensy 4.0, and there are errors, specifically GPIOD_PSOR and GPIOD_PCOR.

The Github has not been updated for a year.

Today I received the two units of Teensy 4.0 that I ordered, I will see if I try things, anyway I already consulted in the PJRC forums and about DMA there is little information.

Some (unfortunate) info on the Teensy 4.0 pins here:

https://forum.pjrc.com/threads/57331-Teensy-4-0-on-high-speed-parallel-bus

I think the most adjacent parallel bits on any one port is six with this Teensy. You’ll have to do some rearranging of your commands to send 7 or eight bit words

With the Teensy 3.x SmartMatrix Library, I need to be able to toggle 7 pins with DMA: 6x RGB pins, 1x CLK. Only having 6 pins available means a much larger redesign of how SmartMatrix Library would work on the Teensy 4.0. Right now it’s looking like the best way of getting Teensy 4.0 to drive large RGB panels at a high frame rate is to use the ESP32-based “co-processor” I’m slowly working on.

Sigh, thanks for the update. Now, if you’re going to use a co-processor, how about using an FPGA which will got must faster than an ESP32 ever will?

FPGAs are expensive as far as I can tell. If you can find me a FPGA with a similar amount of RAM as an ESP32 and comparable price point, I’m interested.

I’m actually making progress on the coprocessor! As of this afternoon, I have a sketch receiving SPI with the APA102 protocol at 4MHz using DMA (I2S In peripheral), writing to a 48bpp SmartMatrix buffer (taking advantage of the GBC bits in the APA102 protocol), refreshing a 64x64 panel at >120Hz 36-bit color. This is running on an ESP32 Pico board, with just a 5V->3.3V level shifter for external circuitry. There’s enough RAM to refresh a 128x64 panel if I add a SmartLED Shield circuit with address latch externally.

128x128 is a stretch goal I’m saving for later. It might be possible, but not easy.

fair point on FPGA price, I’m not up to date on that.
But to be honest, 128x64 is not bad, but likely underwhelming. It’s the size of a single panel now, and with just two of them I can do 128x128.
Now, it’s true that with FastLED::NeoMatrix, which I happen to know the author, of :slight_smile: you can tile multiple APA102 matrices into a bigger logical matrix.
Maybe it’s the best/cheapest we can do for now, one ESP32 per 128x64 panel.

Good to know that about FastLED::NeoMatrix, I will have to give that feature a try.

Maybe it’s the best/cheapest we can do for now, one ESP32 per 128x64 panel.

Do we know of any other microcontroller besides the ESP32 that can refresh a 128x64 panel (with decent color depth and refresh rate)? Do we know of any micro that can refresh a 128x128 panel (or two 128x64 panels)? Raspberry Pi is a Single Board Computer, not a microcontroller, and a much different higher point and larger form factor, and larger complexity.

I think supporting 128x64 is pretty good, and it doesn’t need to be any larger, at least not until a larger panel comes out. Most people aren’t pushing the limits of pixel count like you are :slight_smile:

I was able to drive 2 128x64 panels (i.e. 128x128 total) with a teensy 3.6 but the refresh rate was bad, so I agree that 128x64 seems the highest we can reasonably do between those 2 CPUs.
When I’m not travelling, I want to look into running my code on rPi (I’ve already confirmed rPi runs 128x128 without sweating), but having some integrated solution where an ESP32 backpack can be connected to a 128x64 panel and give an APA102 output, would also be an attractive solution.

You can use an NXP RT1020, it is a Cortex M7 at 500Mhz. Much more powerful than an ESP32 (160-240Mhz), it is an ARM processor and you have a free and professional development environment (MCUXpresso).

Discarding the Teensy 4.0 does not mean not being able to use the NXP RT microcontroller series. Only you have to design your own board with the microcontroller, an LQFP144, which is not difficult to weld, or if you order them to manufacture the ready made board (with the microcontroller already soldered), it will be much simpler.

https://www.mouser.es/ProductDetail/NXP-Semiconductors/MIMXRT1021DAG5A?qs=sGAEpiMZZMu0J0Wcc3HWIhG9ph%2BpHUB507uZXgfZiGm94s1Ut5Nvtg%3D%3D

I have my own design based on a MIMXRT1021DAG5A, it is also very cheap compared to ST STM32H7. Since it has no flash memory, you can boot from QSPI, SD card or hyperflash. You can also add an external SDRAM of up to 256Mbit to load and run the program from RAM, which is even faster.

I enclose my scheme with the RT1020, in order to use the Smartmatrix, porting it to MCUXpresso, which seems to me a much better development environment than Arduino.