AnsweredAssumed Answered

eTPU2 triggered DMA to eQADC

Question asked by Andrei Chichak on Apr 28, 2019
Latest reply on Apr 30, 2019 by Andrei Chichak

I'm working with the MPC5634M, but I expect that many processors have similar peripherals. I'm using gcc in S32DS.

 

My quest is to have engine synchronized ADC readings, rather than uniform timer triggers or random software initiated conversions. I'd love to have DMA delivery of a set of readings that I'll post-process when I get the DMA interrupt, maybe even decimated results. I could have an interrupt and have to go unload the results FIFO. I'll settle for something that smelled like it works. As it is, I've spent two weeks on this section and I can't get the ADC to trigger.

 

I'm using the CRANK and CAM eTPU2 functions to synchronize with a Diesel engine, and this portion works very well. I'm using FUEL and KNOCK on 26 channels and it's very reliable.

 

I have the ADC working with software initiated conversions but, of course, the ADC conversion timing is all over the place and not synchronized with the engine.

 

In the documentation are a few references to using the eTPU to act as a trigger to have the DMA unit feed conversion commands into the FIFOs. Going through app notes AN3396 and AN4209 I've managed to set up an ADC command queue (and I can feed these commands into the FIFO and successfully trigger them via software mode), and I've set up the trigger to look at eTPU channel 31 (apparently only the top 6 channels can be used as triggers).

 

I've set up the DMA unit channel 0 to have a source as my command array, destination as the ADC command queue 0, 32-bits wide, transfer 4 bytes at a time, increment the source, don't increment the destination, just like the sample code in the app notes that use the eMIOS as a trigger.

 

I've set up the eTPU to use the KNOCK function to generate a set of 16 pulses, and I can see these being generated on the output pin via my oscilloscope. They are precisely where I told them to be.

 

I've set up the SIU to feed eTPU31 to the ADC trigger:

 

SIU.ISEL3.B.ETSEL0 = 0x0F; /* 15.8.20 select eTPU channel 31 in the mux */

SIU.ETISR.B.TSEL0 = 0x00; /* Use the mux as the conversion trigger */  /* Section 15.8.17 in RM */

 

I start the ADC to use the "Rising Edge External Trigger, Single Scan" trigger mode.

 

I can look through the ADC device registers and see that the ADC is waiting for a trigger. I can see the eTPU generating the trigger by the trace on my 'scope. I can see the bits set in the SIU to feed the eTPU into the ADC trigger.

 

But will it trigger? NOOOOOOO!

 

I'm in the process of writing a minimal test program that shows the problem, but this includes eTPU, DMA, eQADC, and it takes a while to make small and clear. 

 

Does anybody have any sample code that shows how to do eTPU triggered ADC conversions? Is there a better way, like using the STAC bus to feed in TCR2? Is there some weird feature that I'm missing?

 

I'll post a project once I get something running, or an answer if I stumble across it.

 

Thanks in advance,

Andrei (from the Great White North)

Outcomes