Hey all,

I've configured my 2560 Mega board for a 10-bit PWM output on pins D2 & D3 running at 7.82kHz by setting these registers...

```
//set TCCR3A
//TCCR3A = 0x01; //8-bit
//TCCR3A = 0x02; //9-bit
TCCR3A = 0x03; //10-bit
//set TCCR3B
TCCR3B &= 0x01; //set the prescale = 1 to get the highest pwm frequency
```

I have also created a class to which I can pass a float from 0.0 - 5.0 that sets the mean output of the pwm in volts. This is that class...

```
void DataPoint::begin(float _min, float _max, int _filterWeight,int _maxPWM)
{
//the _min & _max are the limits that can be passed to the Set methodÂ (i.e 0.0, 5.0)
//_filterWeight is the capacity of the moving average (not relevant for my problem)
//_maxPWM is 256, 512 or 1024 depending on the bit level of the PWM
maxPWM = _maxPWM-1;
FilterWeight = _filterWeight;
Min = _min;
Max = _max;
}
void DataPoint::Set(float newSetPoint)
{
//for now, Min is always 0 to make scaling simpler
//get the percent of the analog out
float percentAnalog = (newSetPoint / Max);
//mul the percent by the max PWM output to get the PWMSetPoint
pwmSetPoint = (int)(percentAnalog * maxPWM);
//make sure the pwmSetPoint is in range
if (pwmSetPoint > maxPWM)
pwmSetPoint = maxPWM;
//write the output
analogWrite(controlOutPin, pwmSetPoint);
}
```

This all seems to work fine UNLESS the pwmSetPoint = 255. In that case the pwm signal coming out of D2 or D3 rails to 5V. It's as if I have set a 10-bit PWM to 1023.

Can any one see what the problem is and how to fix it?

Thanks for your time

kevin