🛠 Premiers pas sur le Teensy 4.0 : Teensyduino, Loader et premier Blink

Teensy 4.0 · debutant · Schéma : IMG-teensy-40-debutant-1-teensy40-premiers-pas-blink.svg — Teensy 4.0 vue de dessus (format 1,4 × 0,7 pouce, même empreinte que le Teensy 3.2), flèches sur la LED orange (pin 13), le bouton Program, la LED rouge du bootloader et le port micro-USB ; à côté, la fenêtre Teensy Loader.

Objectives

Get to know the fastest board in its class: the Teensy 4.0 features an NXP MIMXRT1062DVL6 (Cortex-M7 at 600 MHz, officially overclockable to 912 MHz) in the compact 1.4 × 0.7 inch form factor of the Teensy 3.x series. This first tutorial lays the foundations: installing the Teensyduino environment, uploading a Blink sketch, understanding the Teensy Loader + Program button ecosystem (the board has NO hardware reset!), and measuring actual pin speed using the cycle counter.

Hardware

Installation and Uploading

  1. Install the Teensy add-on via https://www.pjrc.com/teensy/td_download.html (official alternatives: PlatformIO, Visual Micro, and the command-line Makefile provided with Teensyduino).
  2. In the IDE: Tools > Board > Teensy > Teensy 4.0, then Tools > USB Type > Serial (the list is long: MIDI, Keyboard, Mouse, Audio, MTP, RawHID…).
  3. Click Upload: Teensy Loader launches automatically. If it does not detect the board, press the Program button on the board — this is NOT a reset button; it requests USB programming mode.
  4. The red LED indicates the bootloader status: dim = waiting, bright = flash writing in progress.

Key architectural point: the bootloader resides in a physically separate chip (a GD32E230F8 on boards after June 2022). The main flash is 100% yours, and uploading cannot destroy it. However, there is no hardware reset pin: you can only reset via software watchdog or via the SCB_AIRCR register.

Complete Code

// Blink + mesure réelle de la vitesse GPIO via le compteur de cycles
// 32 bits ARM_DWT_CYCCNT, incrémenté à la fréquence CPU (600 MHz).
void setup {
  Serial.begin(9600);            // série USB : le baud est ignoré
  pinMode(13, OUTPUT);           // LED orange (JAMAIS en INPUT_PULLUP :
                                 // la LED polarise la broche)
}

void loop {
  uint32_t start = ARM_DWT_CYCCNT;         // instantané du compteur
  for (int i = 0; i < 100000; i++) {
    digitalToggle(13);                     // écriture broche la plus rapide
  }
  uint32_t cycles = ARM_DWT_CYCCNT - start;
  Serial.printf("moyenne %u cycles par bascule\n", cycles / 100000);
  delay(1000);
}

Expected Verification

The orange LED blinks (visually almost off: the loop toggles the pin millions of times per second; digitalToggle compiles to a single bit write). The Serial Monitor displays the number of cycles per toggle — at 600 MHz, around ten cycles correspond to a signal of several tens of MHz on the pin. This is an immediate demonstration of the power of the dual-issue M7 with branch prediction and TCM memory.

Common Errors

Other tutorials for this board

Code examples for this board

← Back to the board 🛠 All tutorials