dp05

ADC conversions to memory via DMA

Discussion created by dp05 on Apr 25, 2013
Latest reply on Apr 26, 2013 by Hui_Ma

I've gone through a few provided sample code examples in addition to the Peripherals Manual, but I've been unable to set up a baremetal example with the an ADC triggering a DMA request after each conversion and putting the 16-bit sample into a 128-byte circular buffer. Currently, it transfers the first sample and then stops. Do the channel registers need to be reinitialized after each transfer in an interrupt? The idea is to fill the buffer in VLPS mode and then wake up the core for analysis. Below is the initial register setup (using Device Initialization to generate init() code):

 

/* SIM_SCGC7: DMA=1 */
  SIM_SCGC7 |= (uint32_t)0x0100UL;                       
  /* SIM_SCGC6: DMAMUX=1 */
  SIM_SCGC6 |= (uint32_t)0x02UL;                       
  /* DMAMUX0_CHCFG0: ENBL=0,TRIG=0,SOURCE=0 */
  DMAMUX0_CHCFG0 = (uint8_t)0x00U;                          
  /* DMAMUX0_CHCFG1: ENBL=0,TRIG=0,SOURCE=0 */
  DMAMUX0_CHCFG1 = (uint8_t)0x00U;                          
  /* DMAMUX0_CHCFG2: ENBL=0,TRIG=0,SOURCE=0 */
  DMAMUX0_CHCFG2 = (uint8_t)0x00U;                          
  /* DMAMUX0_CHCFG3: ENBL=0,TRIG=0,SOURCE=0 */
  DMAMUX0_CHCFG3 = (uint8_t)0x00U;                          
  /* DMA_DSR_BCR0: DONE=1 */
  DMA_DSR_BCR0 |= (uint32_t)0x01000000UL;                       
  DMA_SAR0 = ((uint32_t)&ADC0_RA);
  DMA_DAR0 = ((uint32_t)&MyStaticArray);
  /* DMA_DSR_BCR0: CE=0,BES=0,BED=0,REQ=0,BSY=0,DONE=0,BCR=2 */
  DMA_DSR_BCR0 = (uint32_t)0x02UL;                  
  /* DMA_DCR0: EINT=1,ERQ=1,CS=1,AA=0,EADREQ=1,SINC=0,SSIZE=2,DINC=1,DSIZE=2,START=0,SMOD=0,DMOD=4,D_REQ=0,LINKCC=0,LCH1=0,LCH2=0 */
  DMA_DCR0 = (uint32_t)0xE0AC0400UL;                  
  /* DMAMUX0_CHCFG0: ENBL=1,TRIG=0,SOURCE=0x28 */
  DMAMUX0_CHCFG0 = (uint8_t)0xA8U;

 

 

 

 

Outcomes