LPC17xx, ADC and DMAStarted by 4 years ago●5 replies●latest reply 4 years ago●693 views
Hoping to catch the ear of someone who has used the NXP LPC17xx (specifically, the 1768) device with DMA.
I have given up trying to find a seemingly simple example of DMA - sometimes you wonder how something like this cannot be found on billions of pages, and probably at least hundreds of pages related to this device!
I have 3 ADC channels that I want to read into a buffer of peripheral to memory. I have NXP written code that does this with a single ADC, but not clear how it should be set up for 3 ADC channels. Chapter 31 of manual does not provide me with enough info to understand - heavy on registers, explanations of implementation too shallow. Ideally, I want to sample about every 100ms (perhaps use a timer to trigger) and transfer the 3 ADC values at that interval.
Would someone experienced with this device help me with an approach on how to accomplish this. After searching for hours, I have given up on trying to find an example - it appears this has never been done before ;)
Interleaving DMA is tricky at best. That you want 3 channels of data input at the same time, I'll suggest a simple interrupt that moves all 3.
DMA is single stream (unless they've changed it) so to service 3 streams is to setup & swap parameters for each = inefficient.
I'd pick the "lead" stream, have it trigger an interrupt then transfer all 3 data chunks. Way simpler than 3 DMA streams constantly redirecting source<->destination parameters.
DMA is for single streams to be as fast an I/O as possible. Hard drives were the original, IIRC. Networking followed Much later.
This is irrelevant of processor, data transfers only have N methods.
I think the OP wants to transfer 3 samples from different inputs on the same ADC.
Set up the ADC for burst operation, three channels, select the three channels by setting bits in the ADCxCR register. Set up whatever will trigger the conversion, enable DMA by enabling interrupt generation in the ADC but disabling it for the ADC in the NVIC. (The ADC uses the same signal to generate an interrupt or trigger DMA.)
Then you set up the DMA for a burst of three transfers, peripheral to memory.
I suggest you walk before you run, set it up first for software triggering and make sure you are getting the three channel burst working OK, then move on to DMA. I you only want to sample very 100ms you might do better to not bother with the DMA, let a timer trigger the ADC let the ADC trigger an interrupt when the burst is done (or just scan) .
BTW, I've used other NXP parts but not this one.
The DMA on the LPC1768 supports 8 simultaneous streams or channels, each with independent source, destination, FIFO, and parameters. It only has one ADC but that supports operation in burst mode with channel scanning.
DOH, the LPC has a lot more features than a Freescale 9S08, nice chip.
thanks for answers. yes, a decent part, but as with all Cortex-M parts, by the time a person really understands the thing completely, it's damn near reached obsolescence.
Yes, you are correct - I will not bother with DMA at that rate, it's pretty low, and should not load CPU with that number of interrupts.
I was not aware the ADC had scan mode, I will use that if available (I typically use ST parts which have that feature)