DMA_ADC-K70F120M trigger failure Uergent Uergent ! Thanks!

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

DMA_ADC-K70F120M trigger failure Uergent Uergent ! Thanks!

1,260 Views
Fan_xy
Contributor III

Hello every:

I use TWR-K70,   ADC trigger dma, CW10.6.

1)  When ADC_SC1 -> coco set 1, I use software start DMA,    it can work well;

2) When i use ADC automatic trigger DMA, it can start DMA.

   And I config :

          Master_Adc_Config.STATUS2  =

                                                     | DMAEN_ENABLED     // enable DMA

         DMAMUX_CHCFG_SOURCE(DmaMux_Sou)              // assign DMA trigger source     ,the DmaMux_Sou  is  41

    

      delete the software trigger  DMA ;

other configration is the same as   " 1) "

What's wrong whith me ?

Thank you !

Linda

Labels (1)
0 Kudos
12 Replies

818 Views
adriancano
NXP Employee
NXP Employee

Hi,

You will find useful this Application Note AN4590 and its software AN4590SW here is basically the same philosophy you have for your project. Please refer to the code and document for more information.

I hope this information can help you.

Regards,

-----------------------------------------------------------------------------------------------------------------------

Note: If this post answers your question, please click the Correct Answer button. It would be nice!

-----------------------------------------------------------------------------------------------------------------------

0 Kudos

818 Views
Fan_xy
Contributor III

Hello Adrian,

Thank you !  While I have refered the  Application your suggested.

But , the ADC still can't trigger the DMA.   I have checked all of the regiesters so many times .

The attchment is my project .   TWWR-K70F120M   CW10.6

Thank you very much!

Linda

0 Kudos

818 Views
adriancano
NXP Employee
NXP Employee

Hi,

I am not able to see the attachment, please check that you did not receive any error message uploading the project. Try to attach the project on a .zip file.

Regards,

Adrian

0 Kudos

818 Views
Fan_xy
Contributor III

Hello,

I have upload my project ,

Thank you !

Linda

0 Kudos

818 Views
adriancano
NXP Employee
NXP Employee

Hi,

I am looking at the code you attached but I am not really sure how your configurations are working. I have some doubts and I will give you some hints for the application.

In the main function you are following the next sequence:

1. Enable the clock gates for the Ports and ADC1.

    SIM_SCGC5 = SIM_SCGC5_PORTA_MASK | SIM_SCGC5_PORTB_MASK | SIM_SCGC5_PORTC_MASK | SIM_SCGC5_PORTD_MASK | SIM_SCGC5_PORTE_MASK;

    SIM_SCGC3 |= (SIM_SCGC3_ADC1_MASK );

2. Writing the values for the ADC configuration structure: single conversion, no interrupts, dma enable and prepare the data to read from channel 20 (ADC_SC1_ADCH(20))

3. Enabling DMA channel 1 with:

void Start_Dma(uint8_t Dma_Chn)

{

  DMA_ERQ |= (1 << Dma_Chn);     //enalbe DMA Dma_Chn channle

}

This function is enabling the DMA channel request. It is NOT start DMA transfers.

4. Configuring the ADC with the ADC configuration structure:

ADC_Config_Alt(ADC1_BASE_PTR, &Master_Adc_Config);  // config ADC1

Calling this function writes to the ADCH field that will automatically start the ADC channel 20 conversion. When the ADC channel 20 conversion is finished the COCO flag will SET.

5. Configuring the DMA channel 1:

Dma_Conif(1,30, (uint32_t)(&sou),(uint32_t)(&des),1);

Here you are configuring the DMA channel 0 with the Source 30 as the trigger source. The trigger source for the ADC1 is the 41, you need to write the value 41 for the DMA trigger source request.

Also I see that the function DMA_Config is writing the next:

DMA_ERQ &= ~(1 << Dma_Chn);     //close DMA channle

This instruction will disable the Channel 0 and any request will be serviced, even if the trigger source request it.

I did not test the code to check if it is writing the correct values to the registers. I think that a best sequence to configure the modules is the next (pseudo code):

int main(void)

{

     /* Turn on all port clocks */

     SIM_SCGC5 = SIM_SCGC5_PORTA_MASK | SIM_SCGC5_PORTB_MASK | SIM_SCGC5_PORTC_MASK | SIM_SCGC5_PORTD_MASK | SIM_SCGC5_PORTE_MASK;

     SIM_SCGC3 |= (SIM_SCGC3_ADC1_MASK );

   

     // Write the configuration values to the Master_Adc_Config structure

    

     Dma_Conif(1,41, (uint32_t)(&sou),(uint32_t)(&des),1);        //Configure DMA channel 1 with request source 41 for ADC1

     Start_Dma(1);                                               // Enabling DMA channel 1 that is already configured

     ADC_Config_Alt(ADC1_BASE_PTR, &Master_Adc_Config);  // config ADC1 and initiates the ADC1 channel 20 conversion

}

With this the DMA will be already configured when the ADC conversion ends and the COCO flag is SET.

Please check the points I mentioned and share your results.

I hope this information can help you.

Regards,

-----------------------------------------------------------------------------------------------------------------------

Note: If this post answers your question, please click the Correct Answer button. It would be nice!

-----------------------------------------------------------------------------------------------------------------------

0 Kudos

818 Views
Fan_xy
Contributor III

Hi,

  Dma_Conif(1,41, (uint32_t)(&sou),(uint32_t)(&des),1);    Long ago  I config  41,  while the project can't work, so when I test , i change it , i forget change back. now ,I change it back to 41.

About the source address , i just  to test , so it isn't the ADC result fifo, I think it doesn't matter.

The other place , it haven't problem.

pastedImage_0.png

While the project still can't work well.

Are you sure the ADC can trigger DMA  on K70F120M ?

0 Kudos

818 Views
Kan_Li
NXP TechSupport
NXP TechSupport

Hi Linda,

K70 DMA mux supports ADC0/1 as the DMA request source, but looks like you SW trigger ADC1 before DMA is inited... Please kindly trigger ADC after DMA is initialized


Have a great day,
Kan

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

818 Views
Fan_xy
Contributor III

hi,

1111.png

I really to configu the DMA first ,  then  tirgger adc .

Thank you !

0 Kudos

818 Views
Kan_Li
NXP TechSupport
NXP TechSupport

Hi Linda,

I met the same problem with my TWR-K70, but I found it is due to the DMA driver code.

1. DMA MUX 1 is used in your code, but MUX 1 just control channel 16 - 31, while you treat it as  channel 0 - 15, so that you inited the wrong TCD, that is the main cause of your issue.

2. you assign sou and des to DMA module , but none of them pointing ADC result register, so even you make all things right, the DMA can not access ADC.

3.ADC result is 16bit data, so you have to configure the proper DMA size for it, and seems you selected fixed priority group arbitration, but group1 and group0 share the same priority, so it would cause Group Priority Error when DMA starts.

BTW, you didn't enable DMA interrupt, but in an application, this interrupt is very useful when you want to handle something after the transfer, so I would suggest you enable it in your project.

Please kindly refer to the following project for more details.


Have a great day,
Kan

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

818 Views
Kan_Li
NXP TechSupport
NXP TechSupport

Hi Linda,

Thanks for the clarification, I am testing with your project based 9on TWR-K70F120M, and will let you know when I have any result.


Have a great day,
Kan

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

818 Views
Kan_Li
NXP TechSupport
NXP TechSupport

Hi Linda,

Would you please tell me details about your issue? did you meet issue in the case of item 2 ? What is the issue? Thanks for your patience!


Have a great day,
Kan

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

818 Views
Fan_xy
Contributor III

Hi Kan,

I'm sorry I selling mistake.

In item 2,  "can't  trigger the DMA " .

0 Kudos