is it possible to switch off the power backflow from XIAO SAMD21 up the connected USB-C cable when an additional power source is connected?
According to the Xiao M0 (SAMD21) schematic, there is a diode on the power line, to prevent this. To be more specific, which flavour of XIAO device are you using (there are many different kinds)?
The XIAO_SAMD21 schematic shows a diode, but it may not be implemented.
The following post may be helpful.
I am indeed using SAMD21.
So the diode being removed explains the backflow of power.
So how can I prevent this? By adding the diode? But, I need this behaviour to be switchable.
I’ve used a XIAO combined with other electronics with a 12V battery, dropping the voltage to 5.0V with a 7805 regulator and because the XIAO itself draws relatively low current I put a diode to drop the voltage by 0.6V to about 4.4V, connected to pin 13 - the 5V pin, so it doesn’t compete with the USB. The internal conversion seems happy with this headroom. When the USB is connected its supplying the power, when removed the XIAO is powered from the 4.4V.