Hello to all community.
I'm working with MBD Toolbox v1.4.0 and S32K144EVBQ172 evaboard, and I developed a simple project in order to test the ADC functionality.
Here is my scope:
1) driving two PWM outputs
2) using these PWMs as hardware triggers for two analog inputs channel
3) the triggers should be independent for each PWM, so that: PWM #1 is a trigger for ADC_IN #1, PWM #2 is a trigger for ADC_IN #2 (I can't use a unique trigger for all inputs because, for my final application, I have to sample the input at the middle of high state of the PWM, that varies depending on duty cycle)
I successfully do this if I use the BCTU control mode (Adc_EnableCtuControlMode() call inside the model), but I know that, as described in the RTD ADC user manual, in this way I can't use software triggered conversion group on the ADC Unit controlled by BCTU.
I would try to use both hardware trigger and software trigger, so I tried with BCTU triggered mode, as by default.
I read on the user manual that only one trigger at time is enabled, infact if I enable all hardware triggers contemporarly, only one reading works. So what I did:
a) In model initialization I enable hardware trigger #1
b) when hardware trigger #1 isr callback occurs, inside the callback I disable this trigger, read the related analog input, and enable hardware trigger #2
c) when hardware trigger #2 isr callback occurs, inside the callback I disable this trigger, read the related analog input, and enable hardware trigger #1
And so on.
In this way I can read both hardware triggered and software triggered ADC groups, it's fine.
But there is a behavior I didn't expect, and reading the documentation (also the uC reference manual) I'm not able to find a specific reference to what is happening:
as the two hardware triggers should be served in a single PWM period, I would expect that in any period I have a new trigger and a new conversion for each hw triggered group.
What I see, instead, is that the trigger occurs every two PWM cycles, as if for any period only one trigger was asserted. But actually, as you can see in following picture, I set the PWM outputs in order to have a phase shift between them, in order to be sure not the triggers to be asserted at the same time (I know that, if it would happen, only the trigger with major priority is served):

Yellow waveform: PWM #1
Green waveform: Trigger #1 spycode (toggle on ADC conversion complete isr callback)
Light blue waveform: PWM #2
Purple waveform: Trigger #2 spycode (toggle on ADC conversion complete isr callback)
In zip archive attached to this post you'll find the whole Simulink project, included the mex file with board setup.
I please ask you if you can help me with this behavior, and if this is the right way to implement this kind of control (as said: the BCTU control mode should be ok, but I would try to not loose the possibility to use Adc conversion groups) or if you have a better suggestion for doing so.
Thanks in advance for your support,
Daniel