Please find attached to this thread a Simulink application (and its associated S32CT .mex configuration) developed with MBDT for S32K3 v1.4.0, which uses DMA for transferring converted data from the ADC1 instance, more specifically from the ADC_POT_0 on the S32K344EVB-Q172. The application uses software triggered conversions in single read mode, having a similar look and feel with the s32k3xx_adc_single_read_s32ct model delivered with the toolbox (the difference between them being represented by the DMA data transfer on conversion complete, instead of interrupts).
Please consider performing a backup of the .mex I have attached in a location different than the one where the model is placed, to avoid its overwriting during various tests you may perform with your model.
The steps performed for achieving this use case are described as it follows:
Configuration
1. ADC Configuration
- AdcHwUnit_1, associated to ADC1 has the Transfer Type set on ADC_DMA.
- Adc1Group_0, associated to the ADC1 instance, contains the ADC_POT_0 channel, and it is configured to be triggered by a software source, performing normal conversions, in the one-shot mode.
- ADC1 interrupts were disabled from the AdcInterrupt tab of the Adc component configuration and the DMA support was enabled in the AutosarExt tab.
- AdcHwUnit_1 uses the Adc_Dma_Channel for transfering the data, and this channel is configured inside the Mcl component.
2. DMA Configuration
2.1 Mcl
- Dma_Adc_Channel was configured to use the DMA hardware channel 0
- The Interrupt Callback, executed when the DMA transfer is completed, is configured for Adc_Ipw_Adc1DmaTransferCompleteNotification - this callback is already defined and implemented by the drivers MBDT generates code on top of, and it will be executed from the DMA peripheral interrupt service routine, as detailed below.
2.2 Rm
- DMAMUX needs to be configured being used to route DMA sources to DMA channels - each ADC supports a single DMA request after the conversion of every channel. Hence, inside this component configuration, for DMA hardware channel 0, the Dma Mux Source was configured for a request from the ADC1 instance.
3. Interrupts Configuration
- Interrupt for the DMA Channel 0 must be enabled inside the Platform component - its ISR (Dma0_Ch0_IRQHandler - already defined and implemented by the drivers MBDT generates code on top of) will be executed when the transfer is completed, function which will subsequently call the callback configured inside the Mcl component - Adc_Ipw_Adc1DmaTransferCompleteNotification
4. Clocks Configuration
- Clocks for the EDMA, DMAMUX0 and DMA Channel 0 must be enabled inside the Mcu component. Please note that DMAMUX0 and DMAMUX1 are mapped to the eDMA_TCD 0-15 and 16-31 respectively. Hence, if the DMA Channel 0 is configured for the data transfer, DMAMUX0 clock must be enabled.
Application Implementation
Inside the model, by accessing the Configuration Parameters, the Rm component must be added in the initialization sequence, for DMAMUX initialization, by pressing the Configure Board Initialization button, which can be found under the following settings:
Inside this list, enabling the initialization of the default components MBDT provides support for, custom initialization sequences could be added by pressing the '+' button and inserting the specific code.

Inside the model's Initialize subsystem, the following actions are performed:
- Adc_SetupResultBuffer sets the location in the memory where the ADC results will be transferred via DMA.
- Group Notification is enabled for the Adc1Group_0 to inform on when the data conversion and transfer is completed.
Inside the Simulink top model, the conversion is started, and when the notification (corresponding to a completed data transfer occurs), the data is read inside the ADC_POT0 variable from the ResultBuffer, by the Adc_ReadGroup function.
One additional setting that must be performed inside the model is to declare the ResultBuffer (where the DMA will transfer data) in a non cacheable memory section. When a DMA transfer changes the contents of main memory that has been cached by the processor, the data stored in the cache will have the previous (not updated) value, which might provide inconclusive results while reading the conversion results in this way.
This was implemented by associating to the ResultBuffer signal (which will be used as a variable in the generated code, its address being passed to the Adc_SetupResultBuffer function) a custom defined Storage Class, which places the buffer in a non cacheable memory section. This can be set by accessing the following Simulink model menus: Apps - Embedded Coder - Code Interface - Individual Element Code Mappings.
The noCacheable Storage Class has associated a custom Memory Section, implementing this variable placement in a non cacheable memory section with the help of the drivers Adc_MemMap.h file - contains keywords which control the assignment of variables and functions to specific sections.
A FreeMaster project delivered as well together with the model and the configuration allows the real time visualization of the ADC_POT0 variable based on the potentiometer position.
Hope this helps. Please let me know in case there are any issues in testing this model on your side.
Thank you,
Irina