LPC1769 Fast Fourier Transform

I recently discovered that NXP has published a DSP library for their ARM Cortex-M3 microcontrollers and I thought it would be fun to write an FFT example using my OpenLPC dev board. It works wonderfully!

I apologize for the video of a computer monitor, the screen capture software didn’t run well when trying to refresh the terminal that quickly.

The example code is actually fairly simple seeing as the heavy lifting is done by the pre-complied library. I turn on and set up the on-chip analog to digital converter and then take 1024 samples storing them in SRAM. There are no imaginary samples so I just store 0 every other sample. The array is then sent as an argument to the Fast Fourier Transform function along with a separate pointer to another location in SRAM on the LPC1769 where the results are stored. The magnitude is then calculated and scaled for printing to the terminal. Because I am using a higher resolution FFT I just print a few of the frequency bins (in the video I print 74) so that it will fit on my screen. My current code doesn’t use interrupts and so the sampling frequency depends on the execution time to store the ADC results in  SRAM along with some logic operations and the 65 clock cycles for the actual conversion. When it is all set and done I repeat the process at 20Hz.

The hardware setup was very simple. An arbitrary signal comes from my function generator centered at 1.5V and fed through an RC low pass filter with a cutoff frequency at ~70KHz for anti-aliasing. This is roughly around the Nyquist frequency of the ADC as I am sampling at around 160KSPS. For practical applications this wouldn’t work well and would allow a lot of signals to alias into the sampled signal, however it takes the edge off of what I was working with.

In all it took a couple hours to get everything set up and running correctly. I will clean up my code and use interrupts in the future to get a more predictable sampling frequency. For now my code is available on my GitHub repository.

https://github.com/willhb/lpc/tree/master/fft_adc.lpc17xx