Using DMA how to Transfer ADC value to PWM channel?

Showing results for 
Search instead for 
Did you mean: 

Using DMA how to Transfer ADC value to PWM channel?

Senior Contributor II


I am using FRDM-K20D50M board with codewarrior10.5. I am using PE to generate code. I have written the following code but it is not working. According to me I think there is some minor error which I am not able to find out. I have gone through the app note AN4631. In FRDM board I have connected a potentiometer at ADC0_DM0 and by default the Green LED is connected to  PTD4 FTM0 CH4 . On rotating the potentiometer, the voltage changes from 0 to 3.3v. In the code works fine when not using DMA. Please look into the matter


Kind Regards

Amit Kumar

Original Attachment has been moved to:

0 Kudos
1 Reply

NXP TechSupport
NXP TechSupport

From you description, when there add DMA transfer, the application could not run.

We need to check DMA TCD setting if correct, it use DMA minor loop to transfer 2 bytes data from ADC result register to FTM CnV register and the Major loop is 0x80.

Please set a breakpoint after code run over da = DMA1_Init(NULL); and check DMA registers value.

Please check if TCDn_NBYTES is 0x2 and TCDn_CITER eqaual with TCDn_BITER value to 0x80.

You also could check after ADC start work and DMA CITER register value if modified or not.

Please pay attention that for FTM CnV register update isn't immedicately when new value write into CnV register.

When CLKS[1:0] ≠ 0:0 and 0:0, and FTMEN = 0,  If the selected mode is EPWM, then CnV register is updated after CnV register was written and the FTM counter changes from MOD to CNTIN.

Have a great day,
Ma Hui

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

0 Kudos