🛠 Ingénierie mémoire du Teensy 4.1 : TCM, DMAMEM, EXTMEM, flash QSPI et EEPROM

Teensy 4.1 · avance · Schéma en coupes du i.MX RT1062 du Teensy 4.1 : caches I/D 32 Ko, 512 Ko de RAM1 en TCM accès cycle unique, 512 Ko de RAM2 optimisée DMA (tas malloc), flash QSPI externe 8 Mo (7 936 Ko utilisables) et les deux empreintes QSPI sous la carte pour PSRAM.

Objectives

The Teensy 4.1 is a memory machine: 1,024 KB of RAM (512 KB RAM1 in single-cycle access TCM + 512 KB RAM2 optimized for DMA), 8 MB of QSPI flash (7,936 KB usable, with the upper 256 KB reserved for emulated EEPROM and the backup program), two 32 KB caches, and two empty QSPI footprints under the board for soldering PSRAM. This tutorial consciously places each piece of data in the right location.

Keywords

Complete Code

#include <InternalTemperature.h>

DMAMEM  uint8_t audioBuf[8192];      // RAM2, compatible DMA
EXTMEM  uint8_t bigBuf[1024 * 1024]; // PSRAM : ne lie que si la puce est soudée

const char msg[] PROGMEM = "constante dans le flash QSPI";

void setup {
  Serial.begin(9600);
  while (!Serial && millis < 3000);
}

void loop {
  Serial.print("Temp. die : ");
  Serial.print(InternalTemperature.readTemperature); // capteur embarqué
  Serial.print(" C | tas libre (RAM2) : ");
  Serial.print(malloc_free / 1024);
  Serial.println(" Ko");
  delay(1000);
}

Expected Verification

With a PSRAM chip soldered on the small footprint, the sketch compiles with EXTMEM and the monitor displays die temperature and free heap. Without PSRAM, the EXTMEM keyword causes a compilation error — this is the signal to check the footprint.

Common Errors

Other tutorials for this board

Code examples for this board

← Back to the board 🛠 All tutorials