He already uses FastPWM and not regular PWM (which can't go higher than 1MHz). It should reach 5.3333MHz with the default clock setup. (Btw if you would change the clock, you can still use FastPWM, it uses the actual clock rate, you just need to make sure after changing the clock setup SystemCoreClockUpdate or something similar is called, but as said, 5.33MHz should work with regular clock).
If you have the latest FastPWM version (if you imported it directly you should have it), then repeatedly calling write should work, only in older versions it didn't.
And it should in the period call use double precision by default if you do it like this (indeed regular floats lack precision, which is why FastPWM uses doubles). Might try also using 5430000.0, but I would be surprised if that is the problem.
Now I wanted to start speculating what the problem might be, but basic check: If you run that code, does it start blinking the LEDs? It should do so, unless they decided in the last changes to the mbed they didn't want it anymore (which would be a bad idea). If it indeed blinked the LEDs: This is the error pattern, it is called when an error happens, and if you check your serial terminal it should also give a basic description. (Insta-edit: Checked source code, doesn't do that for sure anymore, only the line number, can't say I am a fan about that).
Back to the actual error: p21 isn't a pwm capable pin on the LPC11u24. These are: https://mbed.org/handbook/PwmOut (actually some others work too, but then you lose all timer, wait, etc options).
Hi, I need to generate a 5.4MHz square wave output from one of the pins on LPC11U24 kit. How could I do this? Help much appreciated!