AnsweredAssumed Answered

pwm using dma transfer datas to cnv

Question asked by FU grace on May 9, 2013
Latest reply on May 13, 2013 by FU grace

hi everyone ,I have this problem for several days and still no solution.

I want to send data to the PWM module's C0V register to change its duty cycle by enable the DMA.

But I really don't know what's wrong with my code .It seems that the DMA transmission is failed because the value of C0V  is always 0.

I have succeed in generating pwm by updating the C0V through the MPU,like below:



  FTM0_C0V = pwm1;




and I've also succeed in transfering datas from memory to memory by using DMA.But it never works when I connect the DMA to PWM register.

By the way ,I'm using the DMA in periodic trigger mode,and I think I have configured the PIT module right.

My code are as follows:


/***channel init***/

void DMAinit(int chno,int sourceno)



     DMA_SERQ|=DMA_SERQ_SERQ(chno) ;//enable the source  chno

     DMAMUX_CHCFG(chno)=(DMAMUX_CHCFG_ENBL_MASK | DMAMUX_CHCFG_SOURCE(sourceno));//enable dma channel chno,

     DMAMUX_CHCFG(chno)|=DMAMUX_CHCFG_TRIG_MASK;//enable the periodic trigger


//DMA controler setting

void DMAset(uint32 *source_addr,uint32 *destiny_address,char sbits,char dbits,char nbytes,char chno,uint16 majorinter )


  uint8 i;

  i =chno ;//DMA  number of channel

  SIM_SCGC7 |= SIM_SCGC7_DMA_MASK; //enable DMA clock

  DMA_SADDR(i) = (uint32)source_addr;//DMA source address

  DMA_DADDR(i) = (uint32)destiny_address;//DMA destiny address

  DMA_NBYTES_MLNO(i)  =2;//minor loop  nbytes

  DMA_ATTR(i)= (DMA_ATTR_SSIZE(sbits)|DMA_ATTR_DSIZE(dbits)) ;//source and dest bits 

  DMA_SOFF(i) =0x2; //source address offset after each transfer

  DMA_DOFF(i)=0x0;/source address offset after each transfer

  DMA_SLAST(i) = -nbytes;   //adjust the source address to the original address

  DMA_DLAST_SGA(i) = -nbytes;    /adjust the destiny address to the original address

  DMA_CITER_ELINKNO(i) =DMA_CITER_ELINKNO_CITER( majorinter);//current major loop counts

  DMA_BITER_ELINKNO(i) = DMA_BITER_ELINKNO_BITER(majorinter);//beginning major loop counts

  DMA_CSR(i)|=DMA_CSR_BWC(3);//bandwidth control


  DMA_CSR(i)|=DMA_CSR_START_MASK;//soft start

  //DMA_SERQ|=DMA_SERQ_SERQ(chno) ;//enable hardware request  chno (have done in the DMAinit)




int main(void)



    hw_pit_init(PIT1,0x249f00);//set the timeout of PIT1




  return 0;