AnsweredAssumed Answered

I2C using DMA

Question asked by ros on Feb 6, 2017
Latest reply on Feb 8, 2017 by AOsama

Hi,

 

I'm using an ADuCM3029 and I'm using the i2c to read in some sensors. But now i need to do some power optimization, so i want to put the micro-controller in FLEXI MODE during RW period. My issue is that the dma isn't working, i can't see any communication on the SDA wire whereas it's working with the classical i2c. Moreover the callback function isn't called at the end of the transfer but all the adi functions return adi_dma_success.

 

I'm using this code to configure the DMA and the I2C:

 

void I2C_cfg()
{
    uint32_t i2c_num = 0;  //I2C0
    
    adi_i2c_Open(i2c_num, ADI_I2C_MASTER, &deviceMemory[0], ADI_I2C_MEMORY_SIZE, &I2C_MasterDev); //initialize I2C in master mode
    adi_i2c_SetBitRate(I2C_MasterDev, 400);       //set Bit rate at 400kHz, without RF we can go from 110kHz to 400kHz
    adi_i2c_SetDutyCycle(I2C_MasterDev, 50);    //duty cycle 50%
    adi_i2c_SetHWAddressWidth(I2C_MasterDev, ADI_I2C_HWADDR_WIDTH_7_BITS);  //component addr on 7b
}

 

void I2C_DMA_cfg()
{
  adi_i2c_EnableDMA(I2C_MasterDev, true);
  ADI_DMA_RESULT eresult=adi_dma_Open(ADI_DMA_CHANNEL_I2CM, memdma, &dma, dma_cb, cbdma);
  if(eresult!=ADI_DMA_SUCCESS)
      printf("dma open fail");
             
  eresult=adi_dma_SetMode (dma, ADI_DMA_MODE_BASIC);
  if(eresult!=ADI_DMA_SUCCESS)
      printf("dma mode fail");
             
  eresult=adi_dma_Enable(dma, false);
  if(eresult!=ADI_DMA_SUCCESS)
      printf("dma enable false fail");
             
  eresult=adi_dma_SetArbitrationRate (dma, ADI_DMA_RPOWER_1);
  if(eresult!=ADI_DMA_SUCCESS)
      printf("dma Rpower fail");
             
  eresult=adi_dma_SetPriority(dma,ADI_DMA_PRIORITY_DEFAULT);
  if(eresult!=ADI_DMA_SUCCESS)
      printf("dma priority fail");
}

 

 

 

And this code to read in the sensor :

 

 

    bool tr=false;
    uint8_t valuedma[6]={0,0,0,0,0,0};
    uint8_t srctab[2]={TARGETADDR_372, addr};
    void* dest=&valuedma[0];
    void* src= srctab;


    dmaDevice.pSrcData=src;
    dmaDevice.pDstData=dest;
    dmaDevice.DataWidth=ADI_DMA_WIDTH_1_BYTE;
    dmaDevice.NumTransfers=8;//8u;//(2u<<6u);//2 bytes to send and 6 bytes to receive
    dmaDevice.SrcInc=ADI_DMA_INCR_1_BYTE;
    dmaDevice.DstInc=ADI_DMA_INCR_1_BYTE;
    
    uint32_t valuedma2[6]={0,0,0,0,0,0};
    uint32_t* p=&valuedma2[0];
    ADI_DCC_TypeDef dma2;
    dma2.DMADSTEND=*p;
    dma2.DMASRCEND=addr;

 


    ADI_DMA_RESULT eresult=adi_dma_Enable(dma, true);
    if(eresult!=ADI_DMA_SUCCESS)
      printf("dma enable fail");
    
    eresult=adi_dma_SubmitTransfer(dma, &dmaDevice);
    if(eresult!=ADI_DMA_SUCCESS)
      printf("dma submit fail");
    
//    adi_pwr_EnterLowPowerMode(ADI_PWR_MODE_FLEXI, &bHibernateExitFlag, 0);
    
    while (tr==false){
      adi_dma_IsTransferInProgress(dma, &tr);
    }
    
    adi_dma_Enable(dma, false);
    adi_i2c_EnableDMA(I2C_MasterDev, false);

 

 

Is there anything I forgot in the settings or a reason for me to not see any values in the destination tab?

 

Thanks in advance,

Outcomes