2020-02-18 02:01 AM
hello
i want to use debug pins as normal gpio pins , is it possible or not?
and if possible then how?
Solved! Go to Solution.
2020-02-18 02:40 AM
The short answer is yes you can.
As to how, at the lowest level (see the Reference Manual), those pins are internally routed to debug (rather than GPIO) by the MODE being set to alternate function i.e. the appropriate bits in GPIOx->MODER are 0b10; you'd want those bits to be 00 for digital input, 01 for output (or 11 for analog).
But there are complications.
Hope this helps; expand on point 1 and we might be able to help further.
Danish
2020-02-18 02:40 AM
The short answer is yes you can.
As to how, at the lowest level (see the Reference Manual), those pins are internally routed to debug (rather than GPIO) by the MODE being set to alternate function i.e. the appropriate bits in GPIOx->MODER are 0b10; you'd want those bits to be 00 for digital input, 01 for output (or 11 for analog).
But there are complications.
Hope this helps; expand on point 1 and we might be able to help further.
Danish
2020-02-18 03:11 AM
You can use them as any other GPIO pin, set them to GPIO input or output mode by changing bits 10-13 in GPIOA->MODER, writing to GPIOA->BSRR or GPIOA->ODR, reading from GPIOA->IDR.
Of course the debugging interface is then no longer available to ST-Link.
To flash a new firmware, you can use the internal bootloader (see AN2606), have ST-Link connect under reset (not all ST-Link clones can do that), assert reset when starting the flashing process, or implement your own bootloader.