I use MK60N512VMD100 Freescale microcontroler and TWR-K60N512 tower system.
I want to run ADC module with DMA.I can run ADC continuously mode, but i can't run DMA module continuously.
DMA->TCD[5].SADDR=(uint32_t)&ADC1->R[0];
DMA->TCD[5].SOFF=0;
DMA->TCD[5].ATTR=DMA_ATTR_SMOD(0)|DMA_ATTR_SSIZE(2)|DMA_ATTR_DMOD(0)|DMA_ATTR_DSIZE(2);
DMA->TCD[5].NBYTES_MLNO=0x00000080;
DMA->TCD[5].DADDR=(uint32_t)&ADC_ConvertValue;
DMA->TCD[5].DOFF=4;
DMAMUX->CHCFG[5]=(DMAMUX_CHCFG_ENBL_MASK|DMAMUX_CHCFG_SOURCE(41));
DMA->TCD[5].CSR|=1;
ADC_ConvertValue must change, when ADC1->R[0] register change.But ADC1->R[0] register is writed only once.DMA isn't working continuously.It is working single mode.
What can I do to make DMA module work continuously?
Hi
1st thing is the same that you dont have to enable the eDMA module by setting "CSR|=1", as it is done by the PIT trigger.
Secondly you would have to configure "Enable Request Register"(DMA_ERQ) in the eDMA module configurations for the channel you are using.
Regards
I have been having a similar problem. I have been working with tech support on this, and they have duplicated my problem exactly. "SR 1-761076978"
If I use software triggering on the ADC, I can use ADC triggered DMA continuously.
If I use PDB to trigger the ADC, it will HW trigger according to the PDB settings
If I enable the HW trigger using the PDB, with the ADC triggering the DMA, only a single conversion executes.
The same effect occurs with the PIT triggereing DMA to move the conversion word into the ADC module if I want the ADC to trigger DMA to get the result
In both cases, when I use a timer to trigger the adc, enabling DMA causes the ADC to only make a single conversion.
IN the PDB case, I get an error indicating the ADC is not ready for a conversion. It is as if using a timer conflicts with useing the ADC triggered DMA transfer of the ADC result.
I have spent hours in the documentation trying to find a reason for this. Further the PIT example in the KQRUG does not work.
Any insight into this would be invaluable. I am using the K40 tower system
I discovered ADC0 does not clear the COCO flag when using DMA to read the value. ADC1 does. My code works with the PDB using ADC1, but not ADC0.
Seems like a bug.
Hi OsmanCagri,
In order to use DMA for continuous operation, you need to trigger the conversion (either by hardware/software), every time you need to transfer data.
In your case you want to transfer ADC conversion result to ADC_ConvertValue at the end of conversion continuously, but you are trigger transfer only once i.e.. By software.
In order to achieve what you want, you need to configure DAM MUX for ADC1, link this request to one of the channel on DMA and configure it accordingly.
Regards
Hi,
Thank you for your suggestion.But,I use trigger mode and channel 3 and it is same problem ADC1->R[1] register is writed only once.
SIM->SCGC6 |= SIM_SCGC6_DMAMUX_MASK;
SIM->SCGC7 |= SIM_SCGC7_DMA_MASK;
SIM->SCGC6 |= SIM_SCGC6_PIT_MASK;
PIT->MCR &= ~PIT_MCR_MDIS_MASK;
PIT->MCR &=~ PIT_MCR_FRZ_MASK;
PIT->CHANNEL[3].LDVAL = 0x0016E25F;
PIT->CHANNEL[3].TCTRL |= PIT_TCTRL_TEN_MASK ;
DMAMUX->CHCFG[3]=(DMAMUX_CHCFG_ENBL_MASK|DMAMUX_CHCFG_TRIG_MASK|DMAMUX_CHCFG_SOURCE(41));//ADC1 Source 41
DMA->TCD[3].SADDR=(uint32_t)&ADC1->R[0];
DMA->TCD[3].SOFF=0;
DMA->TCD[3].ATTR=DMA_ATTR_SMOD(0)|DMA_ATTR_SSIZE(2)|DMA_ATTR_DMOD(0)|DMA_ATTR_DSIZE(2);
DMA->TCD[3].NBYTES_MLNO=0x00000080;
DMA->TCD[3].DADDR=(uint32_t)&ADC_ConvertValue;
DMA->TCD[3].DOFF=4;
DMA->TCD[3].CSR|=1;
Only 0-4 channel have trigger mode.I use channel 3.ADC1 was configured.But,DMA isn't working continuously.
hi
I suppose you have missed the biter and citer to count the minor loop
DMA_TCD0_BITER_ELINKNO=1;
DMA_TCD0_CITER_ELINKNO=1;
as you wanna set the process in a continous mode,so you shall set the loopcont so it could generate a circuit.
Hi,
I had the same problem.
My solution is:
when DMA transfer is completed, not only disable DMA request,
but stop its trigger source(PIT or PDB).
Enable triger source (PIT or PDB), rewrite ADCn_SC1 register,
and initialize DMA when you need to start another DMA.
Hi Osman,
If hardware DMA transfer triggering is used, its not necessary to initiate transfer by explicitly setting START to 1. Can you please try without setting this bit to 1 and check for DMA transfer? Also check is there any error bit being set by eDMA hardware.
Regards,
d2v0
Hi,
When I try without setting CSR register START bit I can't see any value ADC_ConvertValue but if I set START bit I see value.
So, how I test transfer if I don't use START bit?
Hi,
Once you start ADC conversion after you have already setup DMA hardware triggering, the ADC_ConvertValue should change on completion of ADC conversion and DMA transfer by hardware triggering.
Regards,
Dhaval