Yes, you can get 4 MHz from the PWM pins, with code like this:



void setup() {
analogWriteFrequency(2, 4000000);
analogWrite(2, 128);
}

void loop() {