Migrate projet teensy 3.5 to teensy 4.0

good, i was using teensy 3.5 with the code controlling a led panel and it works well.

i bought a teensy 4.0 to try it out.

I changed the arduino program to teensy 4.0 and uploading a lot of errors.

with teensy 3.5 the code works fine, but with teensy 4.0 no longer.

I am attaching the library files configuration that I use in Teensy 3.5

link libraries teensy 3.5 - https://we.tl/t-ciXNfrXTq1

would appreciate help
 

Attachments

  • MatrixHardware_RGB_DMD.h
    4.5 KB · Views: 98
  • SmartMatrix3.h
    7.6 KB · Views: 80
Last edited:
It would be more useful to post the code you tried to use on the T4.
Have you read the file MIGRATION.md in the SmartMatrix-master directory? It describes some changes that are required to get that library working on a T4.

It would also help if you posted some, or all, of the error messages.

Pete
 
thanks , I didn't read the migration file; I removed the library I was using for Teensy 3.5, and installed the new library to use on Teensy 4.0
 
errors in arduino program
 

Attachments

  • Print_Code_Erros.JPG
    Print_Code_Erros.JPG
    151.8 KB · Views: 87
List of errors in arduino program


C:\Users\Pedro\Documents\Arduino\libraries\SmartMatrix-master\src/MatrixHardware_Teensy4_ShieldV0.h:41:17: note: #pragma message: MatrixHardware: SmartLED Shield for Teensy 4 V0

#pragma message "MatrixHardware: SmartLED Shield for Teensy 4 V0"

^

In file included from C:\Users\Pedro\Documents\Arduino\libraries\SmartMatrix-master\src/SmartMatrix4.h:11:0,

from D:\codigo dmd test\Codigo_RGB_DMD_Teensy 4.0\RGB_DMD_Branco\RGB_DMD_Branco.ino:4:

C:\Users\Pedro\Documents\Arduino\libraries\SmartMatrix-master\src/SmartMatrix.h:40:21: note: #pragma message: SmartMatrix Library version 4.000.003

# pragma message "SmartMatrix Library version 4.000.003"

^

BoardInfo: In function 'void readMAC(uint8_t, uint8_t*, uint8_t)':
BoardInfo:50: error: 'FTFL_FCCOB0' was not declared in this scope
FTFL_FCCOB0 = 0x41; // Selects the READONCE command

^

BoardInfo:51: error: 'FTFL_FCCOB1' was not declared in this scope
FTFL_FCCOB1 = word; // Read the given word of read once area

^

BoardInfo:54: error: 'FTFL_FSTAT' was not declared in this scope
FTFL_FSTAT = FTFL_FSTAT_CCIF;

^

BoardInfo:54: error: 'FTFL_FSTAT_CCIF' was not declared in this scope
FTFL_FSTAT = FTFL_FSTAT_CCIF;

^

BoardInfo:57: error: 'FTFL_FCCOB5' was not declared in this scope
*(mac+offset) = FTFL_FCCOB5; // Collect only the top three bytes,

^

BoardInfo:58: error: 'FTFL_FCCOB6' was not declared in this scope
*(mac+offset+1) = FTFL_FCCOB6; // in the right orientation (big endian).

^

BoardInfo:59: error: 'FTFL_FCCOB7' was not declared in this scope
*(mac+offset+2) = FTFL_FCCOB7; // Skip FTFL_FCCOB4 as it's always 0.

^

InputDMD: In function 'void initializeInputDMD()':
InputDMD:99: error: 'PORT_PCR_PE' was not declared in this scope
*portConfigRegister(DMD_DOT_LATCH) |= PORT_PCR_PE;

^

InputDMD:100: error: 'PORT_PCR_PS' was not declared in this scope
*portConfigRegister(DMD_DOT_LATCH) &= ~PORT_PCR_PS;

^

InputDMD: In function 'void configureInputDMD()':
InputDMD:157: error: 'PORT_PCR_MUX' was not declared in this scope
CORE_PIN10_CONFIG = PORT_PCR_MUX(2) | PORT_PCR_PE | PORT_PCR_PS;

^

InputDMD:157: error: 'PORT_PCR_PE' was not declared in this scope
CORE_PIN10_CONFIG = PORT_PCR_MUX(2) | PORT_PCR_PE | PORT_PCR_PS;

^

InputDMD:157: error: 'PORT_PCR_PS' was not declared in this scope
CORE_PIN10_CONFIG = PORT_PCR_MUX(2) | PORT_PCR_PE | PORT_PCR_PS;

^

InputDMD:168: error: 'SIM_SCGC6' was not declared in this scope
SIM_SCGC6 |= SIM_SCGC6_SPI0;

^

InputDMD:168: error: 'SIM_SCGC6_SPI0' was not declared in this scope
SIM_SCGC6 |= SIM_SCGC6_SPI0;

^

InputDMD:169: error: 'SPI0_MCR' was not declared in this scope
SPI0_MCR = SPI_MCR_HALT | SPI_MCR_MDIS | SPI_MCR_PCSIS(1<<0);

^

InputDMD:169: error: 'SPI_MCR_HALT' was not declared in this scope
SPI0_MCR = SPI_MCR_HALT | SPI_MCR_MDIS | SPI_MCR_PCSIS(1<<0);

^

InputDMD:169: error: 'SPI_MCR_MDIS' was not declared in this scope
SPI0_MCR = SPI_MCR_HALT | SPI_MCR_MDIS | SPI_MCR_PCSIS(1<<0);

^

InputDMD:169: error: 'SPI_MCR_PCSIS' was not declared in this scope
SPI0_MCR = SPI_MCR_HALT | SPI_MCR_MDIS | SPI_MCR_PCSIS(1<<0);

^

InputDMD:172: error: 'SPI0_CTAR0_SLAVE' was not declared in this scope
SPI0_CTAR0_SLAVE = SPI_CTAR_FMSZ(15);

^

InputDMD:172: error: 'SPI_CTAR_FMSZ' was not declared in this scope
SPI0_CTAR0_SLAVE = SPI_CTAR_FMSZ(15);

^

InputDMD:175: error: 'SPI0_RSER' was not declared in this scope
SPI0_RSER = SPI_RSER_RFDF_RE | SPI_RSER_RFDF_DIRS;

^

InputDMD:175: error: 'SPI_RSER_RFDF_RE' was not declared in this scope
SPI0_RSER = SPI_RSER_RFDF_RE | SPI_RSER_RFDF_DIRS;

^

InputDMD:175: error: 'SPI_RSER_RFDF_DIRS' was not declared in this scope
SPI0_RSER = SPI_RSER_RFDF_RE | SPI_RSER_RFDF_DIRS;

^

InputDMD:177: error: 'SPI0_POPR' was not declared in this scope
dmaSPI0rx->source((volatile uint16_t&) SPI0_POPR);

^

InputDMD:179: error: 'DMAMUX_SOURCE_SPI0_RX' was not declared in this scope
dmaSPI0rx->triggerAtHardwareEvent(DMAMUX_SOURCE_SPI0_RX);

^

InputDMD:186: error: 'dmaOutputAddress' was not declared in this scope
DMAPriorityOrder(*dmaSPI0rx, dmaOutputAddress);

^

InputDMD:187: error: 'dmaUpdateAddress' was not declared in this scope
DMAPriorityOrder(*dmaSPI0rx, dmaUpdateAddress);

^

InputDMD:210: error: 'IRQ_PORTB' was not declared in this scope
attachInterruptVector(IRQ_PORTB, portb_isr_wpc);

^

InputDMD:218: error: 'IRQ_PORTB' was not declared in this scope
attachInterruptVector(IRQ_PORTB, portb_isr_whitestar);

^

InputDMD:226: error: 'IRQ_PORTB' was not declared in this scope
attachInterruptVector(IRQ_PORTB, portb_isr_sam);

^

InputDMD:242: error: 'IRQ_PORTB' was not declared in this scope
attachInterruptVector(IRQ_PORTB, portb_isr_premier);

^

In file included from C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy4/core_pins.h:32:0,

from C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy4/wiring.h:39,

from C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy4/WProgram.h:45,

from C:\Users\Pedro\AppData\Local\Temp\arduino_build_100103\pch\Arduino.h:6:

InputDMD:245: error: 'IRQ_PORTB' was not declared in this scope
NVIC_SET_PRIORITY(IRQ_PORTB, 32);

^

C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy4/imxrt.h:8897:83: note: in definition of macro 'NVIC_SET_PRIORITY'

#define NVIC_SET_PRIORITY(irqnum, priority) (*((volatile uint8_t *)0xE000E400 + (irqnum)) = (uint8_t)(priority))

^

InputDMD:246: error: 'IRQ_SPI0' was not declared in this scope
NVIC_SET_PRIORITY(IRQ_SPI0, 0);

^

C:\Program Files (x86)\Arduino\hardware\teensy\avr\cores\teensy4/imxrt.h:8897:83: note: in definition of macro 'NVIC_SET_PRIORITY'

#define NVIC_SET_PRIORITY(irqnum, priority) (*((volatile uint8_t *)0xE000E400 + (irqnum)) = (uint8_t)(priority))

^

InputDMD:253: error: 'SPI_MCR_CLR_RXF' was not declared in this scope
SPI0_MCR |= SPI_MCR_CLR_RXF;

^

InputDMD: In function 'void portb_isr_wpc()':
InputDMD:516: error: 'PORTB_ISFR' was not declared in this scope
uint32_t isfr = PORTB_ISFR;

^

InputDMD: In function 'void portb_isr_whitestar()':
InputDMD:618: error: 'PORTB_ISFR' was not declared in this scope
uint32_t isfr = PORTB_ISFR;

^

InputDMD: In function 'void portb_isr_sam()':
InputDMD:673: error: 'PORTB_ISFR' was not declared in this scope
uint32_t isfr = PORTB_ISFR;

^

InputDMD: In function 'void portb_isr_premier()':
InputDMD:728: error: 'PORTB_ISFR' was not declared in this scope
uint32_t isfr = PORTB_ISFR;

^

InputDMD: In function 'void enableDMAPreemption(DMAChannel&)':
InputDMD:846: error: 'DMA_DCHPRI_ECP' was not declared in this scope
DMA_DCHPRI0 |= DMA_DCHPRI_ECP | DMA_DCHPRI_DPA; break;

^

InputDMD:846: error: 'DMA_DCHPRI_DPA' was not declared in this scope
DMA_DCHPRI0 |= DMA_DCHPRI_ECP | DMA_DCHPRI_DPA; break;

^

InputUSB: In function 'bool handleInputUSB()':
InputUSB:197: warning: cast to pointer from integer of different size
dataPtr = (uint8_t*) planes[usbCommand.argument];

^

Watchdog: In function 'void startup_early_hook()':
Watchdog:17: error: 'WDOG_TOVALL' was not declared in this scope
WDOG_TOVALL = 2000;

^

Watchdog:18: error: 'WDOG_TOVALH' was not declared in this scope
WDOG_TOVALH = 0;

^

Watchdog:20: error: 'WDOG_STCTRLH' was not declared in this scope
WDOG_STCTRLH = (WDOG_STCTRLH_ALLOWUPDATE | WDOG_STCTRLH_WDOGEN | WDOG_STCTRLH_WAITEN | WDOG_STCTRLH_STOPEN);

^

Watchdog:20: error: 'WDOG_STCTRLH_ALLOWUPDATE' was not declared in this scope
WDOG_STCTRLH = (WDOG_STCTRLH_ALLOWUPDATE | WDOG_STCTRLH_WDOGEN | WDOG_STCTRLH_WAITEN | WDOG_STCTRLH_STOPEN);

^

Watchdog:20: error: 'WDOG_STCTRLH_WDOGEN' was not declared in this scope
WDOG_STCTRLH = (WDOG_STCTRLH_ALLOWUPDATE | WDOG_STCTRLH_WDOGEN | WDOG_STCTRLH_WAITEN | WDOG_STCTRLH_STOPEN);

^

Watchdog:20: error: 'WDOG_STCTRLH_WAITEN' was not declared in this scope
WDOG_STCTRLH = (WDOG_STCTRLH_ALLOWUPDATE | WDOG_STCTRLH_WDOGEN | WDOG_STCTRLH_WAITEN | WDOG_STCTRLH_STOPEN);

^

Watchdog:20: error: 'WDOG_STCTRLH_STOPEN' was not declared in this scope
WDOG_STCTRLH = (WDOG_STCTRLH_ALLOWUPDATE | WDOG_STCTRLH_WDOGEN | WDOG_STCTRLH_WAITEN | WDOG_STCTRLH_STOPEN);

^

Watchdog: In function 'void kickWatchdog()':
Watchdog:45: error: 'WDOG_REFRESH' was not declared in this scope
WDOG_REFRESH = 0xA602;

^

Watchdog: In function 'void printResetType()':
Watchdog:56: error: 'RCM_SRS1' was not declared in this scope
if (RCM_SRS1 & RCM_SRS1_SACKERR) Serial.println("[RCM_SRS1] - Stop Mode Acknowledge Error Reset");

^

Watchdog:56: error: 'RCM_SRS1_SACKERR' was not declared in this scope
if (RCM_SRS1 & RCM_SRS1_SACKERR) Serial.println("[RCM_SRS1] - Stop Mode Acknowledge Error Reset");

^

Watchdog:57: error: 'RCM_SRS1' was not declared in this scope
if (RCM_SRS1 & RCM_SRS1_MDM_AP) Serial.println("[RCM_SRS1] - MDM-AP Reset");

^

Watchdog:57: error: 'RCM_SRS1_MDM_AP' was not declared in this scope
if (RCM_SRS1 & RCM_SRS1_MDM_AP) Serial.println("[RCM_SRS1] - MDM-AP Reset");

^

Watchdog:58: error: 'RCM_SRS1' was not declared in this scope
if (RCM_SRS1 & RCM_SRS1_SW) Serial.println("[RCM_SRS1] - Software Reset");

^

Watchdog:58: error: 'RCM_SRS1_SW' was not declared in this scope
if (RCM_SRS1 & RCM_SRS1_SW) Serial.println("[RCM_SRS1] - Software Reset");

^

Watchdog:59: error: 'RCM_SRS1' was not declared in this scope
if (RCM_SRS1 & RCM_SRS1_LOCKUP) Serial.println("[RCM_SRS1] - Core Lockup Event Reset");

^

Watchdog:59: error: 'RCM_SRS1_LOCKUP' was not declared in this scope
if (RCM_SRS1 & RCM_SRS1_LOCKUP) Serial.println("[RCM_SRS1] - Core Lockup Event Reset");

^

Watchdog:60: error: 'RCM_SRS0' was not declared in this scope
if (RCM_SRS0 & RCM_SRS0_POR) Serial.println("[RCM_SRS0] - Power-on Reset");

^

Watchdog:60: error: 'RCM_SRS0_POR' was not declared in this scope
if (RCM_SRS0 & RCM_SRS0_POR) Serial.println("[RCM_SRS0] - Power-on Reset");

^

Watchdog:61: error: 'RCM_SRS0' was not declared in this scope
if (RCM_SRS0 & RCM_SRS0_PIN) Serial.println("[RCM_SRS0] - External Pin Reset");

^

Watchdog:61: error: 'RCM_SRS0_PIN' was not declared in this scope
if (RCM_SRS0 & RCM_SRS0_PIN) Serial.println("[RCM_SRS0] - External Pin Reset");

^

Watchdog:62: error: 'RCM_SRS0' was not declared in this scope
if (RCM_SRS0 & RCM_SRS0_WDOG) Serial.println("[RCM_SRS0] - Watchdog(COP) Reset");

^

Watchdog:62: error: 'RCM_SRS0_WDOG' was not declared in this scope
if (RCM_SRS0 & RCM_SRS0_WDOG) Serial.println("[RCM_SRS0] - Watchdog(COP) Reset");

^

Watchdog:63: error: 'RCM_SRS0' was not declared in this scope
if (RCM_SRS0 & RCM_SRS0_LOC) Serial.println("[RCM_SRS0] - Loss of External Clock Reset");

^

Watchdog:63: error: 'RCM_SRS0_LOC' was not declared in this scope
if (RCM_SRS0 & RCM_SRS0_LOC) Serial.println("[RCM_SRS0] - Loss of External Clock Reset");

^

Watchdog:64: error: 'RCM_SRS0' was not declared in this scope
if (RCM_SRS0 & RCM_SRS0_LOL) Serial.println("[RCM_SRS0] - Loss of Lock in PLL Reset");

^

Watchdog:64: error: 'RCM_SRS0_LOL' was not declared in this scope
if (RCM_SRS0 & RCM_SRS0_LOL) Serial.println("[RCM_SRS0] - Loss of Lock in PLL Reset");

^

Watchdog:65: error: 'RCM_SRS0' was not declared in this scope
if (RCM_SRS0 & RCM_SRS0_LVD) Serial.println("[RCM_SRS0] - Low-voltage Detect Reset");

^

Watchdog:65: error: 'RCM_SRS0_LVD' was not declared in this scope
if (RCM_SRS0 & RCM_SRS0_LVD) Serial.println("[RCM_SRS0] - Low-voltage Detect Reset");

^

A utilizar a biblioteca SmartMatrix-master com a versão 4.0.3 na pasta: C:\Users\Pedro\Documents\Arduino\libraries\SmartMatrix-master
A utilizar a biblioteca FastCRC com a versão 1.31 na pasta: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\FastCRC
A utilizar a biblioteca EEPROM com a versão 2.0 na pasta: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\EEPROM
'FTFL_FCCOB0' was not declared in this scope
 
You may be using the correct SmartMatrix library for a T4, but your own code is still expecting a T3.
For example in Boardinfo.ino you have:
Code:
/*
 Read the MAC address
 http://forum.pjrc.com/threads/91-teensy-3-MAC-address
 To understand what's going on here, see
 "Kinetis Peripheral Module Quick Reference" page 85 and
 "K20 Sub-Family Reference Manual" page 548.
*/
void readMAC(uint8_t word, uint8_t *mac, uint8_t offset) {
  noInterrupts();         // Disable interrupts
  FTFL_FCCOB0 = 0x41;     // Selects the READONCE command
  FTFL_FCCOB1 = word;     // Read the given word of read once area

The comment indicates that the code is written for Teensy 3. You will have to find the equivalent function for a Teensy 4.

Similarly, the errors caused by this statement in the configureInputDMD function in InputDMD.ino:
Code:
  CORE_PIN10_CONFIG = PORT_PCR_MUX(2) | PORT_PCR_PE | PORT_PCR_PS;
are because it is specific to the Teensy 3 architecture.

You'll have to figure out how to replace these, and the other errors in Watchdog.ino, with code that works on the Teensy 4.

Pete
 
Thank you, because I am already using the SmartMatrix 4 library.

The question is what kind of changes I will have to make to the code
 
Yes, the problem isn't with the Smartmatrix library.
The problem is that the original code written by Eli Curtz (i.e. all the code in your RGB_DMD_Branco directory) is written specifically for the Teensy 3.2 and uses code which directly accesses the hardware registers of the T3.2.
It will not be an easy task to convert this code to work with the Teensy 4.0 or 4.1.

Pete
 
Back
Top