AnsweredAssumed Answered

K64F PBD/ADC/DMA configuration problem

Question asked by serdar on Dec 22, 2015
Latest reply on Dec 24, 2015 by Alice_Yang

Hi All,

I have been trying to configure PDB/ADC/DMA chain. I achieved PDB and ADC related configuration. PDB is working in one-shot mode for debugging. I saw that ADC conversion is done when I start PDB timer. I also manage configuring DMA to copy memory to memory with manual start but I can't do it for ADC0 to memory.

I am using K64F, Kinetis SDK 1.20, Processor Expert. Could you please check the configuration code and point what I am missing?

Thanks in Advance

Serdar

 

// ADC Config

const adc16_converter_config_t adc_InitConfig0 = {

  .lowPowerEnable = false,

  .clkDividerMode = kAdc16ClkDividerOf1,

  .longSampleTimeEnable = true,

  .resolution = kAdc16ResolutionBitOfSingleEndAs12,

  .clkSrc = kAdc16ClkSrcOfBusClk,

  .asyncClkEnable = false,

  .highSpeedEnable = false,

  .longSampleCycleMode = kAdc16LongSampleCycleOf24,

  .hwTriggerEnable = true,

  .refVoltSrc = kAdc16RefVoltSrcOfVref,

  .continuousConvEnable = false,

  .dmaEnable = true,

};

 

 

const adc16_hw_cmp_config_t adc_HwConfig0 = {

  .hwCmpEnable = false,

  .hwCmpGreaterThanEnable = false,

  .hwCmpRangeEnable = false,

  .cmpValue1 = 0U,

  .cmpValue2 = 0U,

};

 

 

 

 

const adc16_chn_config_t adc_ChnConfig0 = {

  .chnIdx = kAdc16Chn14,

  .convCompletedIntEnable = false,

  .diffConvEnable = false

};

 

 

// PDB config

pdb_timer_config_t adcTimer_InitConfig1 = {

  .loadValueMode = kPdbLoadValueImmediately,

  .seqErrIntEnable = false,

  .clkPreDiv = kPdbClkPreDivBy128,

  .clkPreMultFactor = kPdbClkPreMultFactorAs1,

  .triggerInput = kPdbSoftTrigger,

  .continuousModeEnable = false,

  .dmaEnable = false,

  .intEnable = true,

};

 

// EDMA config

const edma_user_config_t dmaController1_InitConfig0 = {

  .chnArbitration = kEDMAChnArbitrationRoundrobin,

  .notHaltOnError = false,

};

 

 

// init

  ADC16_DRV_Deinit(FSL_ADC);

  ADC16_DRV_Init(FSL_ADC, &adc_InitConfig0);

  ADC16_DRV_ConfigConvChn(FSL_ADC, 0U, &adc_ChnConfig0);

 

 

  PDB_DRV_Deinit(FSL_ADCTIMER);

  PDB_DRV_Init(FSL_ADCTIMER, &adcTimer_InitConfig1);

  //

     PDB_DRV_ConfigAdcPreTrigger(FSL_ADCTIMER, 0, &adcTimer_AdcTrigInitConfig0);

         PDB_DRV_SetTimerModulusValue(FSL_ADCTIMER, 0xFFFU);

         PDB_DRV_SetValueForTimerInterrupt(FSL_ADCTIMER, 0xFFFU);

         PDB_DRV_LoadValuesCmd(FSL_ADCTIMER);

 

 

     // Configure SIM for ADC hw trigger source PDB

     SIM_HAL_SetAdcAlternativeTriggerCmd(gSimBase[0], FSL_ADC, false);

 

 

  EDMA_DRV_Deinit();

  EDMA_DRV_Init(&dmaController1_State, &dmaController1_InitConfig0);

 

 

  // EDMA channel request.

  edmaStatus = EDMA_DRV_RequestChannel(channel, kDmaRequestMux0ADC0, &chnState);

 

 

  edma_transfer_config_t configDMA; // FIXME cikart buradan

  edma_software_tcd_t stcdDmaChn0;

 

 

  // Configure DMA

  configDMA.srcAddr = (uint32_t) (&ADC0_RA);

  configDMA.destAddr = (uint32_t) (images[0]);

  configDMA.srcTransferSize = kEDMATransferSize_2Bytes; // Source data transfer size.

  configDMA.destTransferSize = kEDMATransferSize_2Bytes; // Destination data transfer size.

  configDMA.srcOffset = 0;

  configDMA.destOffset = 2;

  configDMA.srcLastAddrAdjust = 0; // Last source address adjustment.

  configDMA.destLastAddrAdjust = 2; /*!< Last destination address adjustment. Note here it is only valid when scatter/gather feature is not enabled. */

  configDMA.srcModulo = kEDMAModuloDisable; // Source address modulo. FIXME: bu ne

  configDMA.destModulo = kEDMAModuloDisable; // Destination address modulo.

  configDMA.minorLoopCount = 1; // Minor bytes transfer count. Number of bytes to be transferred in each service request of the channel.

  configDMA.majorLoopCount = 1; // Major iteration count.

 

 

  edmaStatus = EDMA_DRV_PrepareDescriptorTransfer(&chnState, &stcdDmaChn0, &configDMA, true, false);

  if (edmaStatus == kStatus_EDMA_Success)

  edmaStatus = EDMA_DRV_PushDescriptorToReg(&chnState, &stcdDmaChn0);

 

 

  // Install callback for eDMA handler

  edmaStatus = EDMA_DRV_InstallCallback(&chnState, edma_isr_callback, NULL);

Outcomes