2025-02-08 11:51 PM - last edited on 2025-02-09 12:18 AM by Peter BENSCH
Hi,
For a project I need 12 ADCs. STM32WL55JCU6 has all the necessary ADCs but two of them are shared with SWDIO and SWCLK pins. Is there any good suggestion for being able to use both these functions at the same time?
2025-02-10 01:36 AM - edited 2025-02-10 01:55 AM
Hello @Emendion
I think it should be possible. You have to implement a SW switcher of functions that create the initialization of the pin for the needed function. After that and when it has to, you should switch the function of the pin. For example, you can initialize the pin as ADC channel. After that, when you need it for SWD. You can stop the ADC channel and reconfigure it for SWD. Then, you can reinitialize the pins and restart the ADC for them after finishing the SWD task.
PS: in this case you can't use the debugger will working on ADC.
Best Regards.
STTwo-32
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2025-02-10 01:49 AM
@Emendion wrote:Is there any good suggestion for being able to use both these functions at the same time?
No - a pin can only do one thing at any one time.
So, as @STTwo-32 suggests, you will have to switch between the two.
But this will mean that the debugger will lose connection while you have the pins switched to ADC mode.
2025-02-10 01:53 AM
Yes, but you will most likely come to regret it.
Use an external ADC.
By the way, I hope you have checked these 12 ADC channels don't include internal ones'.
2025-02-10 03:21 AM
> For example, you can initialize the pin as ADC channel. After that, when you need it for SWD. You can stop the ADC channel and reconfigure it for SWD. Then, you can reinitialize the pins and restart the ADC for them after finishing the SWD task.
I would want to see a life example of this approach.
Without the attached debugger bailing out.
2025-02-10 04:03 AM
Indeed.
IME, Once the debugger has lost connection, it's gone - there is no "resume connection" feature.
2025-02-10 04:33 AM
Hello @Ozone @Andrew Neil
Let me clarify more about that. dynamically, this should be possible to do an alternation on the pin functions. But, about resume connection or not on the debugger. I think this should be tested. But to guarantee a good behavior, maybe the solution of using an external ADC and keep the pins for SWD only will be a very good solution to guarantee the stability as suggested by @Ozone .
Best Regards.
STTwo-32
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2025-02-10 04:51 AM
@STTwo-32 wrote:about resume connection or not on the debugger. I think this should be tested.
So you think is should be possible?
More details, please!
2025-02-10 06:02 AM
> Let me clarify more about that. dynamically, this should be possible to do an alternation on the pin functions
This is out of question - of course it is possible.
What the attached debug pod and the host debugging firmware attached to said debug pod say is a different question. I bet debug access is lost for the entire session.
But the OP initially asking this kind of question here suggests he never did that before, nor has he any experience in working without debug access (JTAG/SWD). In my experience, the probability of running into trouble in this situation is >99% ...
> But to guarantee a good behavior, maybe the solution of using an external ADC and keep the pins for SWD ...
Another viable option would be to add a "debug jumper" (pull-up / pull-down of a GPIO). When set, keep the debug interface, and either reduce the number of ADC channels, fill in "simulated" values, or circumvent the missing channels in another way. When not set, initialize all ADC channels, thereby disabling the JTAG/SWD interface.
But generally, serial ADC are relatively cheap, and more "portable" in regard to protocol and resolution than onboard channels.
As said, I don't know the WL55 variant, but all STM32 MCUs I know have ADC channels with no external interface (Vref, temperature, etc.). I'm not sure he excluded those in his count...