pdb back-to-back mode pretriggers adc issues

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

pdb back-to-back mode pretriggers adc issues

491 次查看
Detective
Contributor I

Why can't I use pdb to trigger 8 adc0 channels? Is there a problem with my configuration? I can trigger adc normally when I use only 6 channels through pdb, but I can't trigger access interrupt once more than 6 channels are used, and 6 can only be triggered when the sampling time is set to 1? Using other samples will not work (I have tried 0-20,24,36, 72,255, etc.) I set the sample time to 12 and can only trigger 4 normally, here is my configuration code:

adc0

Detective_0-1691980092577.pngDetective_1-1691980121401.png

 

 

pdb0

Detective_2-1691980196703.png

adc1

Detective_3-1691980249086.pngDetective_4-1691980259842.png

pdb1

Detective_5-1691980292585.png

code

void ADC0_IRQHandler(void)
{
if(ADC_DRV_GetConvCompleteFlag(INST_ADCONV0,ADC_POC2) == true)
{
/* Get channel result from ADC channel */
ADC_DRV_GetChanResult(INST_ADCONV0, ADC_POC2, (uint16_t *)&g_ADC_Val[ADC_POC2].adcRawValue);
}
if(ADC_DRV_GetConvCompleteFlag(INST_ADCONV0,ADC_POC1) == true)
{
/* Get channel result from ADC channel */
ADC_DRV_GetChanResult(INST_ADCONV0, ADC_POC1, (uint16_t *)&g_ADC_Val[ADC_POC1].adcRawValue);
}
if(ADC_DRV_GetConvCompleteFlag(INST_ADCONV0,ADC_CAM) == true)
{
/* Get channel result from ADC channel */
ADC_DRV_GetChanResult(INST_ADCONV0,ADC_CAM, (uint16_t *)&g_ADC_Val[ADC_CAM].adcRawValue);
}
if(ADC_DRV_GetConvCompleteFlag(INST_ADCONV0,ADC_VCSEL) == true)
{
/* Get channel result from ADC channel */
ADC_DRV_GetChanResult(INST_ADCONV0, ADC_VCSEL, (uint16_t *)&g_ADC_Val[ADC_VCSEL].adcRawValue);
}
if(ADC_DRV_GetConvCompleteFlag(INST_ADCONV0,ADC_POC3) == true)
{
/* Get channel result from ADC channel */
ADC_DRV_GetChanResult(INST_ADCONV0, ADC_POC3, (uint16_t *)&g_ADC_Val[ADC_POC3].adcRawValue);
}
if(ADC_DRV_GetConvCompleteFlag(INST_ADCONV0,ADC_SCREEN) == true)
{
/* Get channel result from ADC channel */
ADC_DRV_GetChanResult(INST_ADCONV0,ADC_SCREEN, (uint16_t *)&g_ADC_Val[ADC_SCREEN].adcRawValue);
}
if(ADC_DRV_GetConvCompleteFlag(INST_ADCONV0,ADC_LIGHT) == true)
{
/* Get channel result from ADC channel */
ADC_DRV_GetChanResult(INST_ADCONV0, ADC_LIGHT, (uint16_t *)&g_ADC_Val[ADC_LIGHT].adcRawValue);
}
if(ADC_DRV_GetConvCompleteFlag(INST_ADCONV0,ADC_RADAR) == true)
{
/* Get channel result from ADC channel */
ADC_DRV_GetChanResult(INST_ADCONV0, ADC_RADAR, (uint16_t *)&g_ADC_Val[ADC_RADAR].adcRawValue);
}
}
 
void ADC1_IRQHandler(void)
{
if(ADC_DRV_GetConvCompleteFlag(INST_ADCONV1, 0) == true)
{
/* Get channel result from ADC channel */
ADC_DRV_GetChanResult(INST_ADCONV1, 0, (uint16_t *)&g_ADC_Val[ADC_PWR_IN].adcRawValue);
}
if(ADC_DRV_GetConvCompleteFlag(INST_ADCONV1, 1) == true)
{
/* Get channel result from ADC channel */
ADC_DRV_GetChanResult(INST_ADCONV1, 1, (uint16_t *)&g_ADC_Val[ADC_MCU_SENSOR].adcRawValue);
}
}
 
static void ADC0_Init(void)
{
g_ADC_Val[ADC_POC2].conf = (adc_chan_config_t*)&adConv0_ChnConfig0;
g_ADC_Val[ADC_POC1].conf = (adc_chan_config_t*)&adConv0_ChnConfig1;
g_ADC_Val[ADC_CAM].conf = (adc_chan_config_t*)&adConv0_ChnConfig2;
g_ADC_Val[ADC_VCSEL].conf = (adc_chan_config_t*)&adConv0_ChnConfig3;
g_ADC_Val[ADC_POC3].conf = (adc_chan_config_t*)&adConv0_ChnConfig4;
g_ADC_Val[ADC_SCREEN].conf = (adc_chan_config_t*)&adConv0_ChnConfig5;
g_ADC_Val[ADC_LIGHT].conf = (adc_chan_config_t*)&adConv0_ChnConfig6;
g_ADC_Val[ADC_RADAR].conf = (adc_chan_config_t*)&adConv0_ChnConfig7;
 
/* Initialize the module and self-calibrate it  */
ADC_DRV_ConfigConverter(INST_ADCONV0, &adConv0_ConvConfig0);
ADC_DRV_AutoCalibration(INST_ADCONV0);
/* Setting the ADC channel  */
ADC_DRV_ConfigChan(INST_ADCONV0,ADC_POC2,g_ADC_Val[ADC_POC2].conf);
ADC_DRV_ConfigChan(INST_ADCONV0,ADC_POC1,g_ADC_Val[ADC_POC1].conf);
ADC_DRV_ConfigChan(INST_ADCONV0,ADC_CAM,g_ADC_Val[ADC_CAM].conf);
ADC_DRV_ConfigChan(INST_ADCONV0,ADC_VCSEL,g_ADC_Val[ADC_VCSEL].conf);
ADC_DRV_ConfigChan(INST_ADCONV0,ADC_POC3,g_ADC_Val[ADC_POC3].conf);
ADC_DRV_ConfigChan(INST_ADCONV0,ADC_SCREEN,g_ADC_Val[ADC_SCREEN].conf);
ADC_DRV_ConfigChan(INST_ADCONV0,ADC_LIGHT,g_ADC_Val[ADC_LIGHT].conf);
ADC_DRV_ConfigChan(INST_ADCONV0,ADC_RADAR,g_ADC_Val[ADC_RADAR].conf);
 
INT_SYS_InstallHandler(ADC0_IRQn, &ADC0_IRQHandler, (isr_t*) 0);
INT_SYS_EnableIRQ(ADC0_IRQn);
 
}
 
static void ADC1_Init(void)
{
g_ADC_Val[ADC_PWR_IN].conf = (adc_chan_config_t*)&adConv1_ChnConfig0;
g_ADC_Val[ADC_MCU_SENSOR].conf = (adc_chan_config_t*)&adConv1_ChnConfig1;
 
ADC_DRV_ConfigConverter(INST_ADCONV1, &adConv1_ConvConfig0);
ADC_DRV_AutoCalibration(INST_ADCONV1);
 
ADC_DRV_ConfigChan(INST_ADCONV1, 0, g_ADC_Val[ADC_PWR_IN].conf);
ADC_DRV_ConfigChan(INST_ADCONV1, 1, g_ADC_Val[ADC_MCU_SENSOR].conf);
 
INT_SYS_InstallHandler(ADC1_IRQn, &ADC1_IRQHandler, (isr_t*) 0);
INT_SYS_EnableIRQ(ADC1_IRQn);
}
 
static void PDB0_init(void)
{
PDB_DRV_Init(INST_PDB0, &pdb0_InitConfig0);
PDB_DRV_Enable(INST_PDB0);
 
PDB_DRV_ConfigAdcPreTrigger(INST_PDB0, 0, &pdb0_AdcTrigInitConfig0);
PDB_DRV_ConfigAdcPreTrigger(INST_PDB0, 0, &pdb0_AdcTrigInitConfig1);
PDB_DRV_ConfigAdcPreTrigger(INST_PDB0, 0, &pdb0_AdcTrigInitConfig2);
PDB_DRV_ConfigAdcPreTrigger(INST_PDB0, 0, &pdb0_AdcTrigInitConfig3);
PDB_DRV_ConfigAdcPreTrigger(INST_PDB0, 0, &pdb0_AdcTrigInitConfig4);
PDB_DRV_ConfigAdcPreTrigger(INST_PDB0, 0, &pdb0_AdcTrigInitConfig5);
PDB_DRV_ConfigAdcPreTrigger(INST_PDB0, 0, &pdb0_AdcTrigInitConfig6);
PDB_DRV_ConfigAdcPreTrigger(INST_PDB0, 0, &pdb0_AdcTrigInitConfig7);
 
PDB_DRV_SetTimerModulusValue(INST_PDB0,(uint32_t) sg_PDBcounter);
PDB_DRV_SetAdcPreTriggerDelayValue(INST_PDB0, INST_ADCONV0, 0UL,(uint32_t) 1);
 
PDB_DRV_LoadValuesCmd(INST_PDB0);
PDB_DRV_SoftTriggerCmd(INST_PDB0);
}
 
static void PDB1_init(void)
{
 
PDB_DRV_Init(INST_PDB1, &pdb1_InitConfig0);
PDB_DRV_Enable(INST_PDB1);
 
PDB_DRV_ConfigAdcPreTrigger(INST_PDB1, 0, &pdb1_AdcTrigInitConfig0);
PDB_DRV_ConfigAdcPreTrigger(INST_PDB1, 0, &pdb1_AdcTrigInitConfig1);
 
PDB_DRV_SetTimerModulusValue(INST_PDB1,(uint32_t) sg_PDBcounter);
PDB_DRV_SetAdcPreTriggerDelayValue(INST_PDB1, 0, 0UL,(uint32_t) 20 );
 
PDB_DRV_LoadValuesCmd(INST_PDB1);
PDB_DRV_SoftTriggerCmd(INST_PDB1);
}
 
The above code adc1 can be polling normally triggered, but adc0 can never trigger 8.
0 项奖励
回复
2 回复数

476 次查看
Detective
Contributor I

The first eight bits are the channels of adc0, and the last two bits are the channels of adc1

When I set the sampling time to 1, sampling only 6 channels will trigger normally, sampling 8 channels will trigger only once, and the 8th channel does not convert, maybe there is a problem with the 7th channel conversion flag? I don't know how to configure it

Detective_0-1691990233120.png

 

When I set the sampling time to 255, sampling 8 channels triggers only the first channel, and no more after that

Detective_1-1691985624338.png

Shouldn't the longer the sampling time be the more accurate the result? Why does it have such a big impact on the sampling value? I have tried many values wrong in the middle, and now I am not sure how to configure it

 

0 项奖励
回复

449 次查看
PetrS
NXP TechSupport
NXP TechSupport

Hi,

you set PDB for continuous mode, so the PDB counter modulo/period must be longer than total conversion of all triggered channels. So what is the value of "sg_PDBcounter" and does it correspond to expected ADC conversion time? Or try to do not use continuous mode and start PDB again after ADC conversion is completed.

BR, Petr

0 项奖励
回复