nvpmodel 0 will slow down the gpio control speed

test 1
tx2 mode: sudo nvpmodel -m 0; sudo /usr/bin/jetson_clocks
Gpio produces square wave frequencies is 71k/hz.

test 2
tx2 mode: sudo nvpmodel -m 3; sudo /usr/bin/jetson_clocks
Gpio produces square wave frequencies is 222k/hz.

questions:I need it to work in mode 0 and the frequency is more than 100k. What’s going on here, How do I fix it?

—code—

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <termios.h>
#include <time.h>
#include <errno.h>
#include <sys/time.h>
#include
#include
#include <unistd.h>
#include “jetsonGPIO.hpp”
#include
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <fcntl.h>
#include <poll.h>

using namespace std;

int main(int argc, char *argv)
{
unsigned int res;
jetsonTX2GPIONumber pin = gpio396;
int fileDescriptor;
char commandBuffer[200];

if (gpioExport(pin) != 0)
{
    gpioUnexport(pin);
    gpioExport(pin);
}
gpioSetDirection(pin, outputPin);

snprintf(commandBuffer, sizeof(commandBuffer), SYSFS_GPIO_DIR "/gpio%d/value", pin);

fileDescriptor = open(commandBuffer, O_WRONLY);
if (fileDescriptor < 0)
{
    char errorBuffer[128];
    snprintf(errorBuffer, sizeof(errorBuffer), "gpioSetValue unable to open gpio%d", pin);
    perror(errorBuffer);
    return fileDescriptor;
}

while (1)
{
    res = write(fileDescriptor, "0", 2); // The time consumed by the function will increase in mode 0
    res = write(fileDescriptor, "1", 2);
}

close(fileDescriptor);

return 0;

}