Update PWM duty cycle with DMA

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

Update PWM duty cycle with DMA

962 次查看
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

标签 (1)
标记 (2)
0 项奖励
回复
1 回复

652 次查看
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 项奖励
回复