News:

PROTON pic BASIC Compilers for PIC, PIC24, dsPIC33

Main Menu

dsPIC33CK256MP508 ADC buffers

Started by Wimax, Aug 15, 2024, 08:35 PM

Previous topic - Next topic

Wimax

Hello everybody! ;)

I am trying to "study" the CK series in order to understand how different the peripherals I have used so far on the Pic24FJ and Pic24HJ with DMA are, especially the ADCs.  From the datasheet of the dsPIC33CK256MP508 for example, the numerous ADCBUFx do not seem to be available to store N successive samples from the same channel and then generate an interrupt to allow them to be processed at a reduced rate, but each channel has its own ADCBUF ? If I operate with a single channel and a trigger provided by a timer at a high rate (over 100 KHz) should I force the MCU to serve an interrupt routine at the same rate ?.

From the diagrams it doesn't seem so clear, I think that for such duties it is necessary to use DMA.  The chapter on DMA seems almost incidental in the data-sheet, but in certain contexts I think it is unavoidable as in the case of multiple high-speed acquisitions on the same channel. Has anyone experienced this ?

Stephen Moss

Quote from: Wimax on Aug 15, 2024, 08:35 PMthe numerous ADCBUFx do not seem to be available to store N successive samples from the same channel and then generate an interrupt to allow them to be processed at a reduced rate
The only devices I have seen that do something like that are those that have a continuous sampling mode, but even then if memory serves those I have seen only had a 4 sample buffer.

If you have enough spare ADC input pins you could create a pseudo version of what you want by connecting the same single to them and switching the channels on the ADC interrupt, but can you not just move the samples into storage for reading later on the ADC interrupt?
I believe at least one example of a rolling buffer has been discussed on the forum before, so perhaps use that and just adjust the size for the number of sample you want to keep.

Wimax

Hi Stephen,

I have gained some experience with continuous sampling with both the Pic24FJ (single-channel) and the HJ series, in the latter case also simultaneously on two channels, but compulsorily by DMA with the HJ. With the Pic24FJ you have 16 - 16 bit buffers, it is convenient and easy to program an interrupt every 16 samples in order to send them to an external RAM, for example. Even operating with sample rates of a few hundred KHz the CPU actually serves the interrupt at a rate of 1/16. With the Pic24HJ, DMA comes into play with a slightly more complex mechanism, but the architecture leaves no choice.
Studying a bit about the architecture of a DsPic33EP512MU810 that I have, but have not yet had a chance to use, I saw that 16-bit buffers are available, but so is DMA. The designer can choose which one to use to handle continuous sampling.

Finally...looking then at the ADC diagrams of the dsPIC33CK256MP508 I was under the illusion that I could use the mechanism of the Pic24FJ or DsPic33EP, then I realised that one buffer is associated with a single channel, hence my doubt.
Looking at the chapter on DMA...I realised that there is little choice with this CK but to rely on DMA, which in this case seems slightly more complex than that of the Pic24HJ series.

trastikata

Hello  Wimax,

DMA is always the better choice! It is quite easy to use:

- dimension an word array variable of the desired size Dim wMyArray(32) as word
- get the address of this array wTemp = AddressOf wMyArray
- set this array as DMA destination in corresponding DMA registers you write wTemp
- set an DMA interrupt after 32 DMA writes
- serve the interrupt - data is already in wMyArray

*You can set a ping-pong buffer which is very useful at high speeds.

Wimax

Hello Trastikata!

First of all many thanks for your precious advises!

I'm taking advantage of some 'free' time to study a little and, at the same time, I try to understand the effort required for a migration from the pic24fj/hj series. I won't hide the fact that I'm very intrigued by the CK series, not only for its speed performance, but also for its power consumption. Comparing the DsPic33EP512MU810 and the DsPic33CK256MP, both operating at 70 MIPS, the latter consumes less than half as much power.