一个应用,需要先使能PDB触发AD,过一段时间后关闭PDB触发AD。
使能PDB触发AD的指令如下:
InitAdcTriggerSource(ADC_INST,0);
InitAdcTriggerSource函数为:
void InitAdcTriggerSource(uint32_t adcInstance,uint32_t preChn)
{
pdb_adc_pre_trigger_config_t pdbAdcTriggerConfig;
pdb_user_config_t pdbUserConfig;
pdb_clk_prescaler_div_mode_t divMode = kPdbClkPreDivBy64;
uint32_t busClock, modValue;
uint8_t preDivider = 1 << divMode;
// get the bus clock freq which for PDB
CLOCK_SYS_GetFreq(kBusClock, &busClock);
// calculate for MOD value
modValue = INPUT_SIGNAL_FREQ*NR_SAMPLES;
modValue = busClock/preDivider/modValue*4;
// init the pdb user config structure for
// enable SW trigger, enable continuous mode,
// set the correct MOD and DLY
// Enable the sequency error interrupt.
PDB_DRV_StructInitUserConfigForSoftTrigger(&pdbUserConfig);
pdbUserConfig.continuousModeEnable = true;
pdbUserConfig.pdbModulusValue = modValue;
pdbUserConfig.intEnable = true;
pdbUserConfig.seqErrIntEnable = true;
pdbUserConfig.clkPrescalerDivMode = divMode;
pdbUserConfig.multFactorMode = kPdbMultFactorAs1;
// Initialize PDB driver
PDB_DRV_Init(0, &pdbUserConfig);
// Configure the PDB channel for ADC_adcInstance
// disable BACK to BACK mode
pdbAdcTriggerConfig.backToBackModeEnable = false;
// enable pretrigger out
pdbAdcTriggerConfig.preTriggerOutEnable = true;
if(0==preChn)
{
pdbAdcTriggerConfig.delayValue = modValue/4;
}
if(1==preChn)
{
// the Pre-trigger A delay is set to 1/4 MOD,
// the Pre-trigger B delay is set to 3/4 MOD,
// so the trigger interval between A/B, B/A is same.
pdbAdcTriggerConfig.delayValue = modValue*3/4;
}
// Configure the pre trigger A for ADC
// PDB_DRV_EnableAdcPreTrigger(0, adcInstance, 0, &pdbAdcTriggerConfig);
// Configure the pre trigger B for ADC
PDB_DRV_EnableAdcPreTrigger(0, adcInstance, preChn, &pdbAdcTriggerConfig);
// Configure SIM for ADC hw trigger source PDB
SIM_HAL_SetAdcAlternativeTriggerCmd(gSimBaseAddr[0], adcInstance, false);
// Trigger the PDB, let it go in continuous mode
PDB_DRV_SoftTriggerCmd(0);
}
关闭PDB触发AD的指令如下:
PDB_DRV_DisableAdcPreTrigger(0, ADC_INST,0);
现在的情况是:
1、使能PDB触发AD,成功
2、关闭PDB触发AD,成功
问题:
一旦关闭PDB触发AD,程序停止运行,现象是UART无输出,GPIO输入输出无响应。
那么如何才能实现:
先使能PDB触发AD,过一段时间后关闭PDB触发AD,又不至于在关闭PDB触发AD后,程序停止运行?
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
一周热门 更多>