大家好,我想为我们的应用程序读取 24 个 ADC 通道,我尝试使用中断方法读取 2 个通道,即 pta0 和 ptc14,当我尝试配置超过 3 个通道时,它正在工作,我不知道如何确定可编程延迟 (pdb)
2 个通道
工作正常,这意味着我收到了中断
PDB_DRV_SetAdcPreTriggerDelayValue(PDB_INSTANCE, 0UL, 0UL,(uint32_t) delayValue/2);
PDB_DRV_SetAdcPreTriggerDelayValue(PDB_INSTANCE, 1UL, 0UL,(uint32_t) delayValue);
这是为 3 个通道配置的,我没有接收到中断
PDB_DRV_Set
timerModulusValue(PDB_INSTANCE, (uint32_t) delayValue);
PDB_DRV_SetAdcPreTriggerDelayValue(PDB_INSTANCE, 0UL, 0UL,(uint32_t) 0);
PDB_DRV_SetAdcPreTriggerDelayValue(PDB_INSTANCE, 1UL, 0UL,(uint32_t) delayValue/3);
3通道的完整代码我没有收到中断
#include "sdk_project_config.h"
#include “interrupt_manager.h”
#include "helper_functions.h"
volatile bool adcConvDone;
易失性 int exit_code = 0;
/* 用户包括 */
#define PDB_INSTANCE 0
#define ADC_INSTANCE 0
#define PDLY_TIMEOUT 1000000UL
IRQn_Type adcIRQ;
/*!
\brief 项目的主要功能。
\details 启动初始化顺序如下:
* - 启动 asm 例程
* - 主要的()
*/
uint16_t adcRawValue,adcRawValue1,adcRawValue2;
静态标志 1、标志 2、标志 3、标志 4;
void ADC_IRQHandler(void)
{
/* 从 ADC 通道获取通道结果 */
如果 (ADC_DRV_GetConvCompleteFlag(0, 0))
{
ADC_DRV_GetChanResult(ADC_INSTANCE, 0U, (uint16_t *)&adcRawValue);
标志 1=1;
}
如果 (ADC_DRV_GetConvCompleteFlag(0, 1))
{
ADC_DRV_GetChanResult(ADC_INSTANCE, 1U, (uint16_t *)&adcRawValue1);
标志2=1;
}
如果(ADC_DRV_GetConvCompleteFlag(0、3))
{
ADC_DRV_GetChanResult(ADC_INSTANCE, 1U, (uint16_t *)&adcRawValue2);
标志 4=1;
}
/* 设置ADC转换完成标志 */
如果(标志 1 && 标志 2 && 标志 4)
{
标志 1=0;标志 2=0;标志 3=1;
PDB_DRV_SoftTriggerCmd(PDB_INSTANCE);
}
}
void clock_pins(无效)
{ status_t 状态;
status = CLOCK_DRV_Init(&clockMan1_InitConfig0);
DEV_ASSERT(状态== STATUS_SUCCESS);
/* 将引脚设置为 GPIO */
status = PINS_DRV_Init(NUM_OF_CONFIGURED_PINS0, g_pin_mux_InitConfigArr0);
DEV_ASSERT(状态== STATUS_SUCCESS);
}
无效 adc0(无效)
{
开关(ADC_INSTANCE)
{
案例 0UL:
adcIRQ = ADC0_IRQn;
休息;
案例 1UL:
adcIRQ = ADC1_IRQn;
休息;
默认:
adcIRQ = ADC1_IRQn;
休息;
}
ADC_DRV_ConfigConverter(ADC_INSTANCE, &adc_config_1_ConvConfig0);
ADC_DRV_AutoCalibration(ADC_INSTANCE);
ADC_DRV_ConfigChan(ADC_INSTANCE, 0UL, &adc_config_1_ChnConfig1);
ADC_DRV_ConfigChan(ADC_INSTANCE, 1UL, &adc_config_1_ChnConfig0);
ADC_DRV_ConfigChan(ADC_INSTANCE, 2UL, &adc_config_1_ChnConfig2);
INT_SYS_InstallHandler(adcIRQ, &ADC_IRQHandler, (isr_t*) 0);
}
无效 pdb0(无效)
{
uint16_t 延迟值;
如果 (!calculateIntValue(&pdb_config_1_timerConfig0, PDLY_TIMEOUT, &delayValue))
{
/* 停止应用程序流 */
同时(1);
}
PDB_DRV_Init (PDB_INSTANCE, &pdb_config_1_timerConfig0);
PDB_DRV_Enable(PDB_INSTANCE);
PDB_DRV_ConfigAdcPreTrigger(PDB_INSTANCE, 0UL, &pdb_config_1_adcTrigConfig0);
PDB_DRV_ConfigAdcPreTrigger(PDB_INSTANCE, 0UL, &pdb_config_1_adcTrigConfig1);
PDB_DRV_ConfigAdcPreTrigger(PDB_INSTANCE, 0UL, &pdb_config_1_adcTrigConfig2);
PDB_DRV_SetTimerModulusValue(PDB_INSTANCE, (uint32_t) delayValue);
PDB_DRV_SetAdcPreTriggerDelayValue(PDB_INSTANCE, 0UL, 0UL,(uint32_t) 0);
PDB_DRV_SetAdcPreTriggerDelayValue(PDB_INSTANCE, 1UL, 0UL,(uint32_t) delayValue/3);
PDB_DRV_LoadValuesCmd(PDB_INSTANCE);
PDB_DRV_SoftTriggerCmd(PDB_INSTANCE);
/* 启用 ADC 1 中断 */
INT_SYS_EnableIRQ(adcIRQ);
}
int 主要(无效)
{
/* 在这里写你的代码 */
时钟引脚();
adc0();
pdb0();
而(1)
{
如果(标志 3)
{
adcConvDone = false;
PDB_DRV_SoftTriggerCmd(PDB_INSTANCE);
}
}
返回退出代码;
}
/* 结束主要 */
/*!
** @}
*/