MPC5746R - BCTU + SAR ADC with DMA transfers of conversion results

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MPC5746R - BCTU + SAR ADC with DMA transfers of conversion results

1,462 Views
lucabarbiero
Contributor IV

Hello,

I am considering a motor control application based on MPC5746R, where motor control tasks would run on the eTPUs and the analog samples would be acquired using the on chip SAR ADCs.

I would use the BCTU to trigger a LIST of conversions (motor currents, voltages etc..) based on a single hardware trigger signal generated by the eTPU.

In the RM, there is one example showing how a LIST of A/D conversions are executed using more than one ADC.

lucabarbiero_0-1610454951272.png

Let's say this is the scenario of interest: 6 analog channels and 2 ADCs used for parallel conversions.

How can I best transfer all conversion results to the eTPU PRAM?

Ideally, I would like to initiate a single collective DMA transfer when all samples are ready, but it does not seem to be possible. According to RM it is possible to raise an interrupt at completion of the LIST, but not start a DMA transfer.

So it seems necessary to transfer each sample with a different DMA channel, when the specific sample is ready. Hence, there would be several atomic DMA transfers instead. Is this the way to go? I don't quite like this idea of:

1. having many DMA channels (6 different DMA channels in the example)

2. not knowing exactly in which order DMA transfers will happen (in the example, which result will be transferred first, between list channels 2 and 3? Or between list channels 4 and 5?)

3. not knowing exactly when all DMA transfers have been completed (if there was just one, this would be easier of course)

All these points are relevant for a safety critical application..

Any suggestions?

BR,

Luca

 

0 Kudos
5 Replies

1,415 Views
lucabarbiero
Contributor IV

Hello @petervlna,

Thank you for the contribution. Indeed I want to avoid by all means any CPU intervention to transfer analog samples from SAR ADCs to eTPU PRAM. That is why my focus is on how to make best use of DMA capabilities.

An idea I have is to use "n" SAR ADCs with n = 1..4 to convert a LIST of  "k*n+1" analog channels with k = 1..2 in practice.

For example n = 3, k = 1. That is, I would use ADC0, ADC1 and ADC2 to convert a total of 4 analog channels.

This means that:

1. the first three channels would be acquired in parallel using the three ADCs.

2. the fourth channel of the LIST would be acquired in a second round using ADC0

3. when the fourth channel result is available and the corresponding DMA transfer is initiated, I can be sure that all the other results are ready to be transferred as well.

Is my reasoning correct? This would not work if the number of conversions were "k*n" or "k*n+2", because I need to have a last non parallel conversion. This would be a workaround to the fact that there is no "LIST completed" DMA event.

 

Regards,
Luca

 

PS: what does FAE stand for? Is this help something I may request through the SafeAssure community? Because I am in that forum as well.

0 Kudos

1,404 Views
petervlna
NXP TechSupport
NXP TechSupport

Hello,

FAE stands for field application engineer.

Regarding your triggering strategy:

I think this will work only in case if there is no delay on any of the ADC conversion.

Safer would be to use some counter which will be updated by DMA each time when the Result is transferred and cleared when one period of measurement is done.

For example (and this will require some feasibility study - its just an idea I have in mind):

Each time the ADC result is copied by DMA, the DMA will have linked DMA channel. This channel will start eTimer and stop it immediately. So the eTimer channel counter will increase just by 1 count. Once all the ADC channels are converted the eTimer channel will reach count of 4 and it will trigger the DMA transfer which will transfer all data into desired location.

Once the Data are transferred, DMA will reset eTimer counter.

This is just an idea, I have done in past some kind of this concept for solenoid control to exclude the core from the measurement concept.

 

Best regards,

Peter

0 Kudos

1,386 Views
lucabarbiero
Contributor IV

Thank you Peter,

I don't feel like I want to implement something like that, but your inputs convinced me that the problem is indeed not that simple to tackle. I have decided with my team for a simpler approach:

1. Trigger a BCTU LIST of conversions from the eTPU

2. Let each SAR ADC channel result register do its own DMA transfer. We won't have control over the order in which DMA transfers following parallel conversions happen, the order will be random from my understanding. We just accept that.

3. The eTPU waits a fixed amount of time, which from offline analysis is deemed greater than the worst case acquisition time for the LIST of analog channels.

4. In the eTPU thread that processes the converted analog samples, we can check the data valid flag, that is part of the conversion result registers. If it set, then the data is fresh. We reset the flag in the eTPU memory and then check if it is set again at the start of next time frame.

5. In the CPU we should be able to count how many DMA transfers happened over a period of time (this check will be done asynchronously, no interrupt from BCTU, SAR ADC or eTPU), so to know if indeed as many DMA transfers happened as we would have expected.

6. Take action in case the checks 4. and 5. reveal that something is wrong.

This is how we intend to proceed. If you have further comments, that's welcome. Otherwise thank you for your time.

Regards,

Luca

0 Kudos

1,421 Views
petervlna
NXP TechSupport
NXP TechSupport

Hello,

How can I best transfer all conversion results to the eTPU PRAM?

For sure the most elegant way is to use DMA. But you can also relly on simple interrupts and transfer data by core.

Ideally, I would like to initiate a single collective DMA transfer when all samples are ready, but it does not seem to be possible. According to RM it is possible to raise an interrupt at completion of the LIST, but not start a DMA transfer.

So it seems necessary to transfer each sample with a different DMA channel, when the specific sample is ready. Hence, there would be several atomic DMA transfers instead. Is this the way to go? I don't quite like this idea of:

1. having many DMA channels (6 different DMA channels in the example)

2. not knowing exactly in which order DMA transfers will happen (in the example, which result will be transferred first, between list channels 2 and 3? Or between list channels 4 and 5?)

If the conversion speed is constant then you will have the same order as you set in ETPU. (well in case you are not mixing 2 different asynchronous measuring systems).

3. not knowing exactly when all DMA transfers have been completed (if there was just one, this would be easier of course)

You will get DMA done flag from DMA channel.

All these points are relevant for a safety critical application..

I can understand your concept and concerns. There is also possibility to trigger LIST interrupt and start DMA in interrupt and transfer all data at once.

There is also possiblity to link DMA channels so if you know that your last ADC channel was converted and the DMA transfer is triggered from it you can transfer all results by DMA at once with linked channel.

 

This is not an easy application task, if you want to exclude core from it.

It will require detailed feasibility study and I expect it will also require help of FAE as this is safety related.

 

best regards,

Peter

1,444 Views
lucabarbiero
Contributor IV

Hello, any comments or pointers to example solutions for this use case? Thanks a lot for any help.

0 Kudos