S32K3 ADC Optimize DMA Streaming

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

S32K3 ADC Optimize DMA Streaming

102 Views
Jason22
Contributor III

Hello,

When the adc group has only one channel and the Adc Enable Optimize DMA Streaming Groups configuration item is checked, a hard fault occurs when the Adc_Ipw_SetupTcdSingleAdcChannelMajorLink function is executed.

In the case of a single channel, if the Adc Group Without Interrupts configuration item is checked and ACCESS_MODE_STREAMING, Select Adc Streaming Dma Channel is enabled. Otherwise, the number of the dma channel in the configuration file is 255, which is reasonable here. But what I don't understand is why when ADC_ENABLE_GROUP_STREAMING_RESULTS_RORDER or ADC_OPTIMIZE_DMA_STREAMING_GROUPS is STD_ON, instead of STD_ON==GroupPtr ->AdcWithoutInterrupt, the Adc_Ipw_SetupTcdSingleAdcChannelMajorLink function will be called. This seems unreasonable, and also because the call to this function leads to hard fault.

Jason22_0-1785831767968.png

BR,

Jason

 

Tags (3)
0 Kudos
Reply
4 Replies

70 Views
Senlent
NXP TechSupport
NXP TechSupport

Hi@Jason22

Please do not use your QQ email account next time; please use your company email account instead.

I tested this, but I didn't find any problems.

I have attached my test project and test result for your reference.

 

Also, i check your code and i found some error in your code.

1.clock init is wrong, your code can't not run successfully,

Senlent_0-1785915417329.png

 

2."adc_group0_val" should be attribute to "no-cacheable area"

 

also:

The usage instructions for Optimize DMA streaming groups are clearly explained in the user manual.

RTD_ADC_UM.pdf

Senlent_0-1785915908665.png

 

 

0 Kudos
Reply

30 Views
Jason07
Contributor I

Hi@Senlent

The picture in the last reply is not clear. I have uploaded the picture again in the form of attachment. I numbered the order of the pictures with numbers.

BR,

Jason

0 Kudos
Reply

32 Views
Jason07
Contributor I

Hi@Senlent

Thank you very much for your reply. I have registered a new account using my company email address, and I will use that account after this thread is closed.

I ran your project and found that no hard fault occurred. However, my question still remains. As shown in the screenshot below, the function Adc_Ipw_SetupTcdSingleAdcChannelMajorLink configures the DMA_IP_CH_SET_MAJORLOOP_LOGIC_LINK_CH parameter for the DMA channel. When Dma_Ip_ConvertLogicChToHwCh is called, the LogicCh value is 255. Dma_Ip_pxInit->ppxLogicChannelConfigArray points to the Dma_Ip_paxLogicChannelConfigArrayPB array, which has a size of 2. Accessing Dma_Ip_pxInit->ppxLogicChannelConfigArray[255] should be an out‑of‑bounds access. Although no hard fault occurred, I believe this is not reasonable.

Jason07_0-1785979871220.png

Jason07_1-1785979890128.png

Jason07_2-1785979907208.png

This out‑of‑bounds access is caused by calling Adc_Ipw_SetupTcdSingleAdcChannelMajorLink, which is another question I have. I have reviewed the relevant content in RTD_ADC_UM.pdf and also checked the driver code. For Optimize DMA Streaming Groups (single channel), the data is transferred directly from the CDR to the user buffer, unlike the multi‑channel case where data is first moved from the CDR to the DmaIntermediateBuffer and then from there to the user buffer. Optimize DMA Streaming Groups (single channel) does not use a Streaming DMA channel. In the configuration file, the values of AdcIpwConfigPtr->Mapping.AdcCountingDmaChanLogicId array are indeed ADC_IPW_INVALID_DMA_CHANNEL_ID (255).

Jason07_3-1785980010767.png

I do not understand why Adc_Ipw_SetupTcdSingleAdcChannelMajorLink still needs to be called. The function that really should call this is Without Interrupt Group (single channel), but when ADC_ENABLE_GROUP_STREAMING_RESULTS_RORDER or ADC_OPTIMIZE_DMA_STREAMING_GROUPS is STD_ON, instead of STD_ON == GroupPtr ->AdcWithoutInterrupt, the Adc_Ipw_SetupTcdSingleAdcChannelMajorLink function is called.

Jason07_4-1785980037684.png

I have found the issue in my project: when I uncheck "Data sections", the hard fault no longer occurs. However, I do not think this is the key point of the problem.

Jason07_5-1785980062079.png

BR,

Jason

0 Kudos
Reply

4 Views
Senlent
NXP TechSupport
NXP TechSupport

Hi@Jason07 @Jason22

Please set the optimization build option to -O0 .

This is the result I observed during single-step debugging.

Senlent_1-1786003373031.png

 

This is likely because the build optimization (-Os) prevents the debugger from accurately mapping source code variables.

 

 

0 Kudos
Reply