Update PWM duty cycle with DMA

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

Update PWM duty cycle with DMA

748 Views
antoniomagrì
Contributor II

Hello everyone,

 

I am new to Kinetis microcontrollers and Kinetis SDK development, I own a TWR-KV31120M board and I am trying to set a project up in KDS using SDK and PE.

 

I was able to create a PWM output and change its duty cycle in software, but I am now trying to update the value from RAM using DMA.

 

I created and configured a fsl_edma component:

 

16521_16521.pngconfig.png
This led to the generation of initialization code for DMA, which initializes DMA, requests a channel, and installs a callback function.

 

If I understand correctly now it's up to me to configure the loop with EDMA_DRV_ConfigLoopTransfer and start it with EDMA_DRV_StartChannel.

 

I am trying to have the content of a 16-bit variable, pwmduty, to the TPM0_C0V register (also 16-bit).

 

This is the way I am doing the calls to the functions:

 

 

if (EDMA_DRV_ConfigLoopTransfer(&dmaController1_ChnState0,&descriptor,

                                                       kEDMAMemoryToPeripheral,

                                                       (uint32_t)&pwm_duty,

                                                       (uint32_t)&FTM0_C0V,

                                                       2,

                                                       2,

                                                       2,

                                                       0

     ) == kStatus_EDMA_Success) {

 

     EDMA_DRV_StartChannel(&dmaController1_ChnState0);

}

 

While the code above is executed (and the first call returns success) I placed a breakpoint on the callback function and never see it called in debug...

 

Do you know what am I doing wrong?

 

Thank you very much for any suggestion you may have.

 

Best regards,

 

Antonio

Labels (1)
Tags (2)
0 Kudos
1 Reply

438 Views
adriancano
NXP Employee
NXP Employee

Hi,

Are you are adding the <driver_name>_irq.c file to your project? Please refer to this document in the section Troubleshooting: I’m trying to use a driver and keep falling into the default ISR


Hope this information can help you.

Best Regards,
Adrian Sanchez Cano
Technical Support Engineer
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos