Teensy 3.5 PWM

Hello

I have a Teensy 3.5 and i want to generate a PWM. This is the code i`m running:

const int redPin =  2;

void setup()   {                
  pinMode(redPin, OUTPUT);
  Serial.begin(9600);
}

void loop()                     
{
  if(Serial.available())
  {
    int data = Serial.parseInt();
    Serial.print(data);
    Serial.println();
    analogWrite(redPin, data);
  }
}

I type the values from 0 to 255 in the serial monitor, and it generates a PWM with that value. The problem is this:

-> i type 255 -> the pwm RMS (on the oscilloscope) says 3.27V - almost a 3.3V
-> i type 127 -> the pwm RMS says 2.31V.... it should be 1.635 aprox.... but the duty cycle says 48.8%

What am i getting wrong?

-> i type 255 -> the pwm RMS (on the oscilloscope) says 3.27V - almost a 3.3V

OK

-> i type 127 -> the pwm RMS says 2.31V.... it should be 1.635 aprox.... but the duty cycle says 48.8%

No, first a meter will not always measure rapidly pulsing voltages correctly. But most important is that RMS is not the appropriate measure for this. A 50% duty cycle will give you 50% reduction in the average not the RMS.