Content originally posted in LPCWare by OldManVimes on Wed Sep 03 04:29:03 MST 2014
I'm doing something like what you want, but on a LPC12xx, so any comments I make may or may not apply to the LPC11xx.
I sample every used ADC channel in burst mode at one specific sample frequency. I can control the frequency by changing ADC prescaler. The rest is explained in detail in the user manual. It explains how many clock cycles one ADC sample takes and you extrapolate for the number of ADC channels in use combined with the peripheral clock rate. You then apply a formula that takes these variables as input and that calculates the ADC prescaler value such that the sampling frequency of the ADC channel(s) is what you want. (Sorry, I do not have any code handy, so I'm a bit sketchy on details).
Then I make the ADC I'm interested in trigger an interrupt. Inside the ISR I queue the sample (the A/D conversion has already taken place). This means the amount of jitter on the sampling is as low as can be. The downside is that only a limited number of frequencies are possible, but given a high enough peripheral clock it is pretty good. I've added code to my solution that can measure the ADC interrupt interval to verify that I'm getting the expected sampling frequency. That helps to check the correctness of the calculations.
Then again a timer may do the trick as well, but this way my CPU load is exceedingly low which I find important. Handling the queue contents is then handled by regular code outside of interrupt context. Burst mode ADC is a pretty cool feature.
Hope this helps,
Vimes