Arm Mbed and Pelion Device Management support forum

Very poor performance on lpc1768

I’ve been trying to do some simple loops with the lpc1768. Due to form factor, I’m using the mbed board.
The issue is extremely poor performance; trying to drive the dac I’m getting about 1 cycle every two seconds, generating a sine wave. I took everything out of my code save the loop in main (just to test) and
cannot explain this terrible performance. On a different form factor lpc1768 using keil, the performance is great, and I can do 8k sine waves.
Does anyone have any feedback about this? I’d like to dump the mbed.h and compile just my keil code, but I get a lot of duplicate defines, (__ARM, for example) that don’t exist in my code.
Has anyone else had these performance issues?

Thank you

Hi Jack,
Can’t say I’ve had any problems with my LPC1768.
Are you using the On-Line compiler and which library, MbedOS or Mbed 2?
Try it on both and if you are using MbedOS, try it using the baremetal build, see here:

Otherwise can you post your code that you are experiencing issues with and I’ll try it.


Thank you for your quick reply. This isn’t my code, but an example I found:
#include “mbed.h”

DigitalOut myled(LED1);
AnalogOut Aout(p18);

//Note if w_hat is pi/4 this means 8 samples/period. If we measure frequency of this output signal.
//then reconstruction frequency is 8 times this.
//Could put it through a low pass filter to smooth out.
//Also check the offset.

//Sine wave reconstruction in this case is much faster(tahn test4_sine) since I calculate the sample values before hand.
//Sine wave period is 2.2*5us = 12us
//Sine wave freq = 83KHz
//Reconstruction freq is 666KHz

unsigned short n;
#define pi 3.1415192
#define N 64 //Numebr of samples in one period
#define w_hat 2*pi/N //Normalised radian frequency
float sine1 [N]; //contains sine wave sample values

void init_sine_array(void);

int main() {
while(1) {

        Aout = sine1[n];


void init_sine_array(void)
unsigned short n = 0;
for (n=0;n<N;n++)
sine1[n] = 0.5 + 0.5sin(nw_hat); //note the 0.5 V of offset since DAC outputs voltage between 0 and 3.3V


My code is similar, but uses a file of data instead of the sine wave.