Dear NXP support,
I have an S32K344 with which I try to set up the ADC. I'm using RTD 2.0.0. On ADC0 I want to have a group "GROUP_NORMAL" configured with normal hardware trigger and a group "GROUP_INJ" with injected hardware trigger (that will stop the normal conversion of GROUP_NORMAL if that would be ongoing).
As normal hw trigger I use a GPT PIT and as injected hw trigger I use an eMIOS as source. In the reference manual and the RTD documents related to the ADC (ADC User manual and ADC Integration manual) I can't find anything that suggests that this combination of trigger for an ADC instance would not be possible.
However, with this configuration after initialisation (after calibration) only setup of the first group works and not the second, i.e. with the code
Adc_SetupResultBuffer(GROUP_NORMAL, setupResultBuffer0);
Adc_SetupResultBuffer(GROUP_INJ, setupResultBuffer1);
Adc_EnableHardwareTrigger(GROUP_NORMAL);
Adc_EnableHardwareTrigger(GROUP_INJ);
only GROUP_NORMAL are actually doing conversion, not GROUP_INJ. After some investigation in the debugger I found that in Adc_EnableHardwareTrigger() the program end up in Adc_ValidateNotBusyEnableHwTrig() (which returns E_NOT_OK) where the following information is in a comment:
/* It's possible to run (normal HW - injected SW) or (injected HW - normal SW) combination */
This comment explains why my trigger combination does not work. But where is this mentioned in the manuals?
How can I implement my trigger combination? I do not want to do a workaround by going via a SW trigger as the trigger should not depend on the SW application state. I believe this a quite a basic implementation case, so how should I proceed? What are your solutions and suggestions? Using the BCTU in control mode for ADC0 instead would be ok if no SW trigger is required.
Best regards,
Olof
Hi olof1,
I confirmed that hw normal and hw inject trigger can't be enabled at same ADC hw unit.
ADC driver follow ASR spec:
As description about Inject Conversion in UM that was attached in the package:
So, if you don't want to use SW trigger, you need to use BTCU control mode instead of trigger mode.
Best regards,
Nhi
Hi,
Thank you for your answer.
However, as I understand the behavior of the BCTU control mode, if the ADC is busy with a conversion triggered by a low priority trigger, a higher priority trigger will NOT inject the ongoing conversion but it will instead wait until the ongoing (low priority) conversion is finished.
This behavior is not equivalent to my desired implementation of one hw normal trigger and one hw injected trigger at the same adc hw unit. I have high priority channels related to PWM for which I want conversion to start directly, while the other adc channels I just want to be updated so update frequency and timing is not as important.
I want to implement this in hw only, is that even possible? What are your suggestions?
Best regards,
Olof
Hi @olof1 ,
From my point of view, I think that you can try with this suggestion:
- Normal Hw trigger: source trigger from PIT,... not from BTCU.
- Inject Hw trigger: source trigger from EMIOS that always have higher priority.
You can use the functions:
- Adc_EnableHardwareTrigger () -> Normal Hw trigger.
- Adc_EnableCTUTrigger() -> Inject Hw trigger
Best regards,
Nhi
Hi @Nhi_Nguyen ,
Thank you for your answer. However, I can't get your suggestion to work. As you suggested, I'm using Adc_EnableHardwareTrigger() for the normal hw trigger and Adc_EnableCTUTrigger() for the bctu hw injected trigger. I call Adc_EnableHardwareTrigger() first and then Adc_EnableCTUTrigger(), which once again fails in Adc_ValidateNotBusyEnableHwTrig()... see image. I also tried flipping the order I call the enable hw trigger functions, only the one I call first will start its group conversion.
The if statement ends up in the empty else branch, i.e. ValidState stays E_NOT_OK.
It seems as Adc_axUnitStatus[Unit].OngoingHwGroup is also used for BCTU triggers? And there can only be one hw trigger per adc unit? What am I missing to get your suggestion to work?
When I removed the Adc_ValidateNotBusyEnableHwTrig() check, both groups successfully started conversions, so without this check it seems to work.
Using RTD 2.0.0 but looked at RTD 3.0.0 and the code seems to be the same.
Best regards,
Olof
Hi @olof1 ,
SW team confirmed that have no way to use hw trigger inject and hw trigger normal together for current driver for both non ASR functions and ASR functions. The problem is not only at the function Adc_ValidateNotBusyEnableHwTrig() but also interrupt/DMA handling after data converted.
Best regards,
Nhi
Hi @olof1 ,
From my point of view, Adc_EnableCTUTrigger() is non-ASR function, it should break limitation of ASR requirement and follow to HW support. It means that Adc_EnableCTUTrigger() and Adc_EnableHardwareTrigger() can be called together without error. I'll contact to SW team and come back to you when I get their response.
Best regards,
Nhi