Encoder inputs, maximum frequency?

Hello,
I connected a linear encoder to the inputs of the Portenta Machine Control. Using just the "Encoders" example, I get some values.

However, it seems quite slow...

On moving the axis faster and faster between like 0 and 500mm, it seems that the Portenta starts to lose increments at a certain speed.
At first, I thought, that the 24 -> 3,3V level converter may be the issue, but the signals look fine at the inputs of the Portenta H7. (tested up to 500kHz)
Up on testing, the issue of losing increments starts at around 40 or 50 kHz, which seems really low for a 480 Mhz microcontroller...

I tested this with the old "Machine Control" and the new "Portenta Machine Control" library.

Since I could not find anything in the datasheet:
What is the maximum frequency for the encoder inputs?
(Or do I something wrong here?)

Do you use a hardware counter or the software implementation?

It's the example from the Portenta lib:

/*
 * Portenta Machine Control - Encoder Read Example
 *
 * This sketch shows the functionality of the encoders on the Machine Control.
 * It demonstrates how to periodically read and interpret the values from the two encoder channels.
 *
 * Circuit:
 *  - Portenta H7
 *  - Portenta Machine Control
 *
 * This example code is in the public domain. 
 * Copyright (c) 2024 Arduino
 * SPDX-License-Identifier: MPL-2.0
 */

#include <Arduino_PortentaMachineControl.h>

void setup() {
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect.
  }
}

void loop() {
  Serial.print("Encoder 0 State: ");
  Serial.println(MachineControl_Encoders.getCurrentState(0),BIN);
  Serial.print("Encoder 0 Pulses: ");
  Serial.println(MachineControl_Encoders.getPulses(0));
  Serial.print("Encoder 0 Revolutions: ");
  Serial.println(MachineControl_Encoders.getRevolutions(0));
  Serial.println();
 
  Serial.print("Encoder 1 State: ");
  Serial.println(MachineControl_Encoders.getCurrentState(1),BIN);
  Serial.print("Encoder 1 Pulses: ");
  Serial.println(MachineControl_Encoders.getPulses(1));
  Serial.print("Encoder 1 Revolutions: ");
  Serial.println(MachineControl_Encoders.getRevolutions(1));
  Serial.println();

  delay(25);
}

I guess, thats the software solution? 
How do I access the hardware counter? 

@kutt did you find the problem ? Did you find how to use high frequency encoders ?