Set Timer interrupt to control DMA get ADC data

cancel
Showing results for 
Search instead for 
Did you mean: 

Set Timer interrupt to control DMA get ADC data

588 Views
anniehung05911
Contributor II

Hi,

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_EnableChannel(DMA0, DEMO_ADC_DMA_CHANNEL);
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?

Thanks.

Labels (1)
  • QN

0 Kudos
3 Replies

340 Views
Sebastian_Del_Rio
NXP TechSupport
NXP TechSupport

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:

 pastedImage_2.png

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.

 

Best regards,

Sebastian

0 Kudos

340 Views
anniehung05911
Contributor II

Hi,

Thank you for your reply,

I configue DMA_ITRIG_INMUX by adding the following code in main function,

INPUTMUX->DMA_ITRIG_INMUX[4];

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>

ctimer_config_t config;
ctimer_match_config_t matchConfig;

CTIMER_GetDefaultConfig(&config);
CTIMER_Init(CTIMER, &config);
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);
CTIMER_StartTimer(CTIMER);

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?

Thanks.

0 Kudos

340 Views
Sebastian_Del_Rio
NXP TechSupport
NXP TechSupport

Hi Wei-Min Hung,

 

  1. Each of the Standard Counting Timers included in the QN9080 has 4 different match registers, each with a different configurable value, depending on the selected match configuration, the DAM transfer will activate either on the match 0 or match 1 values.
  2. The configuration of the timer for this purpose involves changing the value for the corresponding match register, so that when the TC matches the register, it generates an interrupt or a DMA transfer. You'll have to change the MCR register to allow the transfer to the desired match register.
  3. Each of the internal CTIMERs has different MATCH registers, and for DMA transfer, you can use either 0 or 1 of each of the CTIMERs.

 

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").

 

Best regards,

Sebastian

0 Kudos