Slew Rate Limiting Option - Teensy 4.1

PGPH

Member
IMG_20250902_183354.jpgAs shown in the attached picture, I have generated with a teensy 4.1 pulses of about 125 nanoseconds which show suprisingly quite high initial and final oscillations.

To test the impact of the SRL, I have then tried without success to Disable/Enable the option with the following instructions (commented in the here below initial code):
CORE_PIN2_CONFIG &= ~PORT_PCR_SRE;
CORE_PIN30_CONFIG |= PORT_PCR_SRE;

Compilation of the modified code stopped with following error message:
'PORT_PCR_SRE' was not declared in this scope
17 | CORE_PIN2_CONFIG &= ~PORT_PCR_SRE;
| ^~~~~~~~~~~~
exit status 1
Compilation error: 'PORT_PCR_SRE' was not declared in this scope

In an attempt to fix this, a few libraries where included in the code, but did not solve the problem.

I am curently stuck!

Thank you in advance for helping me on this subject.

___________________________________________
Code:
#include <Wire.h>
#include <WireIMXRT.h>
#include <WireKinetis.h>
#include <TeensyThreads.h>
#include <buffer.h>
#include <color.h>
#include <gfxfont.h>
#include <_Teensy.h>
#include <imxrt.h>

void setup()
{
  pinMode(2, OUTPUT);

  // Disable SRL
  // PORT_PCR_SRE set to 0 (default).
  // CORE_PIN2_CONFIG &= ~PORT_PCR_SRE;

  // Enable SRL
  // CORE_PIN30_CONFIG |= PORT_PCR_SRE;

  test();
}

void test()
{
  while(true)
  {
    digitalWriteFast(2, HIGH);
    delayNanoseconds(100);
    digitalWriteFast(2, LOW);
    delayNanoseconds(400);
  }
}

void loop()
{
}
 
Thank you Joe.

Based on your suggestion, I tried the following command line to disable the SRL:
CORE_PIN2_CONFIG &= ~IOMUXC_PAD_SRE;

Supprisingly, the pulses disappear completely!

Any idea as to why?
 
Hello Paul.
Without writing to the IOMUXC register (the command line I just mentioned) I get the pulses shown before.
 
Thank you MarkT for your suggestion to make the connection cable to the scope a resistive probe.
I understand you imply that this could help filtering out the high frequency oscillations.
I will certainly do this later, but for the time being I am trying to see the effect of the Slew-Rate-Limiting option.

I already noticed in the past that inserting a 220 ohms resistor just after the Teensy improved significantly the signal, which made me believe that the oscillations were part of the generated signal from the Teensy.

Since my last post, I have tested the following change, which had surprisingly still no impact on the pulse shape:
replace
CORE_PIN2_CONFIG &= ~IOMUXC_PAD_SRE;
by
IOMUXC_SW_PAD_CTL_PAD_GPIO_B0_12 &= ~IOMUXC_PAD_SRE;
 
If there's an unterminated cable it will resonate all be itself - resistance will damp any resonances. But for full bandwidth you have to terminate with a matched load.
 
Some further investigation to check the impact of the Slew-Rate-Limiting option on the pulse shape.

I found that Pin 2 native name on Teensy 4.1 is not B0_12, as I inittially thought, but EMC_04 (source is KurtE's pinout-chart referred to on PJRC Web site).

With the help of ChatGpt :), I also found how to manipulate the PAD register.
Here is what I did to get the pulse shape shown on the attached picture.

Code:
  // Set all bits of the PAD Register to mofify the options, including SRL/SRE. 
  IOMUXC_SW_PAD_CTL_PAD_GPIO_EMC_04 =
  (0 << 16) |   // Bit#16     HYS = 0    (Hysteresis : OFF)
  (0 << 14) |   // Bit#15-14  PUS = 0    (Pull-UP / Pull-Down : 100 kohms pull-down)
  (0 << 13) |   // Bit#13     PUE = 0    (Pull Selection : KEEPER)
  (0 << 12) |   // Bit#12     PKE = 0    (Pull Keeper : OFF)
  (0 << 11) |   // Bit#11     ODE = 0    (Open-Drain : PUSH-PULL)
  (0 << 6)  |   // Bit#7-6    SPEED = 00 (Commutation Speed : 50 Mhz)
  (2 << 3)  |   // Bit#5-3    DSE = 010  (Drive Strength : ~130 ohms)
  (0 << 0)  ;   // Bit#0      SRE = 0    (Slew Rate Limiting : LOW)

After experimenting on different bit settings, I concuded the following:
1) By default, all bits are set to 0 , except DSE bits which are 111 (~37 ohms).
2) SRE set to 0 or 1 doesn't change anything.
3) DSE is the only parameter that has an impact; decreasing its value reduces signal oscillations/ringing.

Any comment is welcome.
 

Attachments

  • IMG_20250907_151638.jpg
    IMG_20250907_151638.jpg
    203.1 KB · Views: 75
Back
Top