Recently, I am using S32K144 (2ADC module with a total of 32 AD channels) to realize the function of AD multiplexing. But I am facing a complex requirement.
need:
The 2 AD channels are sampled at the middle point of the 1 PWM (frequency 1KHz, duty cycle varies with function).
21-way AD polling sampling, preferably 5ms, 10ms is also fine.
What is fixed is:
1. FTM (INIT trigger in CPWM mode) - "TRGMUX;
2. The 21-way AD polling uses PDB->AD;
There are two ideas:
1. FTM-"TRGMUX-"PDB-"AD Put two ADs with special requirements into R0 of ADC0 and R0 of ADC1 respectively, this should be feasible, but AD polling depends on FTM's init_trg, and the sampling frequency is 1ms.
2. FTM->TRGMUX->Two special ADs; LPIT interrupt (software-trigger)->PDB->23 ADs. Two of the special ADs are still placed first. These two modes are switched in the 1ms interrupt of LPIT.
Personally, I would like to try the second method, but the problem is that I don't know how fast the switching of the ADC's pre-trigger source and trigger source in the SIM will affect the AD convert process.
最近我在用S32K144(2ADC 模块 共 32 AD通道)实现AD多路采集的功能。 但是我面对一个复杂的需求。
需求:
2路AD通道在1路PWM(频率1KHz,占空比随功能变化)的中间点采样。
21路AD轮询采样,最好是5ms,10ms也行。
固定的是:
1、FTM(CPWM模式的INIT触发)-》TRGMUX;
2、21路的AD轮询使用PDB-》AD;
现有两种思路:
1、FTM-》TRGMUX-》PDB-》AD 分别把两路特殊要求的AD放到ADC0的R0和ADC1的R0,这样应该是可行的,但是AD轮询依赖到FTM的init_trg 上 ,而且采样频率是1ms。
2、FTM-》TRGMUX-》两路特殊AD; LPIT中断(software-trigger)-》PDB-》23路AD。其中两路特殊AD仍然放到最先。 这两种模式在LPIT的1ms中断中切换。
个人很想试一试第二种方法,但是问题是,并不知道在SIM中对ADC的预触发源和触发源切换有多快,会对AD convert 过程产生什么影响。
more question ,lower M pre-trigger. is it means that only 12 AD channel can be used in each AD module.
if it is like that SC1[M] to SC1[P] is useless in this MCU, is it correct, Could somebody help me?
我大约明白了你的需求,就是想在PWM的中心位置实现ADC的同步采样,其实我们有这样相关的例程,在我们的电机控制方案中对电压和电流采样时,使用的是FTM->TRGMUX->PDB->ADC,PDB可以预触发采样ADC,ADC采样完成还会有中断COCO的标志反馈,这个是只有PDB和ADC之间才有,如果你使用LPIT模块可能有一些麻烦,第一个就是LPIT预触发通道有限,其次软件需要判断ADC是否才有完成,第三个你还得要同步LPIT和FTM之间的计数关系,如果你用LPIT的时候又使用PDB,这个感觉是多此一举。