I'm using QN9080 DK with SDK_2.x_QN908XCDK
I want to get ADC data by DMA controller
I want to set the timer for DMA that DMA will follow the timer regular transfer ADC Data
ex. set Timer every 4 ms use DMA to transfer ADC [ &DEMO_ADC_BASE->DATA ]
Refer to the sample code of qn908xcdk_driver_examples_adc_dma
I found that there are some api maybe for setting DMA Transfer
#define DEMO_ADC_DMA_CHANNEL 14
DMA_CreateHandle(&g_adcDmaHandle, DMA0, DEMO_ADC_DMA_CHANNEL);
DMA_PrepareTransfer(&transferConfig, (void *)&DEMO_ADC_BASE->DATA, &g_AdcConvResult, sizeof(uint32_t), 4, kDMA_PeripheralToMemory, NULL);
How to set the DMA for this question?
Hi Wi-Min Hung, I hope you're doing well!
The QN908x's DMA peripheral is highly configurable and has 20 different available channels to transfer data. These channels can each have a user-configured priority and can be configured to respond to two different types of activations: either a DMA request or a trigger event.
If you want to use a timer to start a DMA transfer, you'll have to configure the channel's DMA_ITRIG_INMUX registers to select the correct trigger source:
In the case of a CTIMERx initiated DMA transfer, the transfer will start whenever the timer's value is equal to the configured CTIMER match value.
For further DMA information, you can check the DMA driver examples included with the QN908x's SDK.
Also, chapter 12 of the User Manual for the QN908x has some additional information about the functionality of the DMA controller.
Please let me know if you have any further questions.
Thank you for your reply,
I configue DMA_ITRIG_INMUX by adding the following code in main function,
Q : Is it mean I selet DMA trigger #4 >> timer CTIMER0 Match 0 DMA request ?
By Setting CTIMER, I refer the sample code - ctimer_simple_match
1. Include the fsl_ctimer.h library,
2. Add the following code in main function, >> But it didn't trigger DMA
#define CTIMER CTIMER0 /* Timer 0 */
#define CTIMER_MAT_OUT kCTIMER_Match_2 /* Match output 2 */
#define BUS_CLK_FREQ CLOCK_GetFreq(kCLOCK_ApbClk)
<in Main function>
matchConfig.enableCounterReset = true;
matchConfig.enableCounterStop = false;
matchConfig.matchValue = BUS_CLK_FREQ / 2;
matchConfig.outControl = kCTIMER_Output_Toggle;
matchConfig.outPinInitState = true;
matchConfig.enableInterrupt = false;
CTIMER_SetupMatch(CTIMER, CTIMER_MAT_OUT, &matchConfig);
Q : How to configure the CTIMER, that I can use CTIMER to trigger DMA ?
Q : And problem for CTIMER, what is the different between Match 0 and Match 1?
Hi Wei-Min Hung,
For further reference, you can read sections 12 (DMA transfer) and 14 (CTIMER 0 to 3) of the QN908x User Manual.
You can also check some of the examples included in the QN9080 SDK, specifically the CTIMER Simple Match and Simple Match Interrupt examples for reference on correct CTIMER configuration. ("…\SDK_2.2.0_QN908XCDK\boards\qn908xcdk\driver_examples\ctimer").