AnsweredAssumed Answered

S32K DMA传输ADC数据

Question asked by 王 云 on Nov 13, 2018
Latest reply on Nov 22, 2018 by 王 云

#S32K ADC DMA :由FTM1每隔1ms触发PDB0,PDB0设置pretrigger 3个ADC0通道,3个ADC0通道采集完一遍通过DMA中断读取。之前用过采集4路ADC并通过DMA读取,但是改成3通道时进入不了中断,不知道是不是DMA传输ADC只支持特定的通道数。

配置程序如下,接收RecordBuf_ADC0[3]是uint32_t类型,ADC通道从2~4, 请大佬们帮忙分析一下问题:

 DMA->TCD[0].CSR &= ~DMA_TCD_CSR_DONE_MASK;   
 DMA->TCD[0].ATTR = DMA_TCD_ATTR_SMOD(4)  |    /*这个设置成0也不行*/    

                                      DMA_TCD_ATTR_SSIZE(2) |      /*Source data transfer size32bit*/            
                                      DMA_TCD_ATTR_DMOD(0)  |              
                                      DMA_TCD_ATTR_DSIZE(2);        /*Destination data transfer size 32 bit*/      
 DMA->TCD[0].NBYTES.MLNO = DMA_TCD_NBYTES_MLNO_NBYTES(3);   
 DMA->TCD[0].CITER.ELINKNO = DMA_TCD_CITER_ELINKNO_CITER(3) |  
                                                        DMA_TCD_CITER_ELINKNO_ELINK(0);   
 DMA->TCD[0].BITER.ELINKNO = DMA_TCD_BITER_ELINKNO_BITER(3) |  
                                                        DMA_TCD_BITER_ELINKNO_ELINK(0);   

 DMA->TCD[0].SADDR = DMA_TCD_SADDR_SADDR(&(ADC0->R[2]));    
 DMA->TCD[0].SOFF  = DMA_TCD_SOFF_SOFF(4);      
 DMA->TCD[0].SLAST = DMA_TCD_SLAST_SLAST(0);       /*Last source address adjustment 改成-12=4byte/channel*3channel 也不行*/

 DMA->TCD[0].DADDR = DMA_TCD_DADDR_DADDR(RecordBuf_ADC0);  
 DMA->TCD[0].DOFF  = DMA_TCD_DOFF_DOFF(4); 
 DMA->TCD[0].DLASTSGA = DMA_TCD_DLASTSGA_DLASTSGA(-12);     
 DMA->TCD[0].CSR = DMA_TCD_CSR_BWC(0)         |           
                                    DMA_TCD_CSR_MAJORELINK(0)  |           
                                    DMA_TCD_CSR_MAJORLINKCH(0) |          
                                    DMA_TCD_CSR_ESG(0)         |                                  

                                    DMA_TCD_CSR_DREQ(0)        |          
                                    DMA_TCD_CSR_INTHALF(0)     |          
                                    DMA_TCD_CSR_INTMAJOR(1)    |          
                                    DMA_TCD_CSR_START(0);                  

Outcomes