Why in 'PWM Adc Dma 344 S32CT' Example it's used the ISR block to read the dma adc channel

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Why in 'PWM Adc Dma 344 S32CT' Example it's used the ISR block to read the dma adc channel

366 次查看
simon98
Contributor III

Hi NXP Team,

I'm working on a project using S32K358 in MBDT and i'm looking for enabling the DMA trasfer type of ADC modules.

In the ADC example 'PWM Adc Dma 344 S32CT' i've found that to read the data of the ADC1 group, configured in DMA mode, it is used the Hardware Interrupt Block as wall as the ADC2 groups configured in Interrupt mode.

simon98_1-1739551777853.png

 

My question is why it is used this block and if it's necessary in order to read the values of the ADC1 group. Does this gruop generate interrupt at the end of conversion although configured in DMA mode?

Calling the Adc_ReadGroup function elsewhere doesn't work the same?

 

Thanks,

Simon

 

 

标记 (5)
0 项奖励
回复
1 回复

340 次查看
Irina_Costachescu
NXP Employee
NXP Employee

Hi @simon98 

MBDT generates code on top of RTD (Real-Time Drivers) that we integrate inside our toolbox for configuration and control of the peripherals. Based on how these drivers are implemented, the Adc_Adc1Group0Notification is called from the Adc_Ipw_Adc1DmaTransferCompleteNotification.

The Adc_Ipw_Adc1DmaTransferCompleteNotification is configured inside the Mcl component, in the Dma configuration tab, as illustrated below.

 mclcallback.png

This callback is called from the Dma interrupt handler (Dma0_Ch0_IRQHandler), and it is used to report that the DMA data transfer is completed. However, this function does not provide user access, for implementing desired actions when this event occurs, hence the Adc_Adc1Group0Notification is used for this purpose. In other words, the Adc_Adc1Group0Notification can be seen more as a user callback, a place where application specific actions can be implemented when certain events occur, and not as an Interrupt Service Handler.

Please see below the stack of functions being called, inside the drivers, for reaching the Adc_Adc1Group0Notification function in the mentioned application.

debugstack.png

Hence, after the conversion is completed, and the data transferred to the ADC result buffer, the Adc_ReadGroup function, called inside the Adc_Adc1Group0Notification, reads the converted data from the buffer and places it inside the ADC_POT0 variable. The evolution of the ADC_POT0 can be seen inside the FreeMASTER project associated to the model.

The interrupts mechanism is used inside this application to make sure that data is accessed after the conversion and its transfer to the configured buffers is performed. If you would like to use directly the Adc_ReadGroup function, this would be a possibility as well, however, you would need to make sure that the data is available at the moment of trying to access it. This is not an use case that we have implemented in our application examples.

If you would like to find our more about the Adc implementation inside the RTD, you could download and install the S32 Design Studio IDE, import the Simulink generated code inside the IDE, and debug it step by step.

Moreover, I would also like to mention that in this example ADC2 has a different configuration and behavior - the conversion of its groups are hardware triggered, via BCTU, by two PWM signals. Hence, ADC2 is not related to the DMA functionality of the model.

Hope this will help,
Irina

0 项奖励
回复