Closed flute2k3 closed 1 year ago
Currently we don't yet automatically disable the JTAG / SWD pin remapping functions if we see those pins being used.
Can you try this manually as the first line in setup()
?
gpio_pin_remap_config(GPIO_SWJ_DISABLE_REMAP, ENABLE);
might need DISABLE
instead of ENABLE
if it doesn't work.
Oh, actually that would completely disable JTAG + SWD (you might need to hold down reset and release it at the right time during the flashing process if you can't flash it now).
Reference manual chapter 8.4.3 says
So if you use SWD to flash it, you should be able to do
gpio_pin_remap_config(GPIO_SWJ_SWDPENABLE_REMAP, ENABLE);
instead, that makes PB3 available.
sorry to say, but both DISABLE and ENABLE does not work. I use ST-link to flash
Mhh I think it must be the second line, after you did the pinMode()
because then the clock for the AFIO peripheral is activated and the command becomes valid.. I'll check on my hardware.
Or manually
rcu_periph_clock_enable(RCU_AF);
first.
Basically what I'm saying is
#include <Arduino.h>
#define LED PB3
void setup()
{
rcu_periph_clock_enable(RCU_AF);
gpio_pin_remap_config(GPIO_SWJ_SWDPENABLE_REMAP, ENABLE);
pinMode(LED, OUTPUT);
}
void loop()
{
digitalWrite(LED, LOW);
delay(100);
digitalWrite(LED, HIGH);
delay(100);
}
super, it works but I get this error 0x2ba01477 Error: init mode failed (unable to connect to the target) in procedure 'program' OpenOCD init failed shutdown command invoked
*** [upload] Error 1
by press the reset button works with flashing. I'm happy with it now. thank you again!
Did you upload with GPIO_SWJ_SWDPENABLE_REMAP
or GPIO_SWJ_DISABLE_REMAP
? You're connecting via the SWDCLK (PA14) + SWDIO (PA13) lines?
Try also connecting the NRST of the ST-Link to the (N)RST line of the board.
Also,
you might need to hold down reset and release it at the right time during the flashing process if you can't flash it now
I've actually just pulled in the API for the afio_cfg_debug_ports()
function, see
Can I ask you to update again and use the sketch
#include <Arduino.h>
#define LED PB3
void setup()
{
// switch to "SWD only", releasing PA15, PB3 and PB4
// from their original JTAG function.
afio_cfg_debug_ports(AFIO_DEBUG_SW_ONLY);
pinMode(LED, OUTPUT);
}
void loop()
{
digitalWrite(LED, LOW);
delay(100);
digitalWrite(LED, HIGH);
delay(100);
}
as a test?
I've actually just pulled in the API for the
afio_cfg_debug_ports()
function, seeCan I ask you to update again and use the sketch
#include <Arduino.h> #define LED PB3 void setup() { // switch to "SWD only", releasing PA15, PB3 and PB4 // from their original JTAG function. afio_cfg_debug_ports(AFIO_DEBUG_SW_ONLY); pinMode(LED, OUTPUT); } void loop() { digitalWrite(LED, LOW); delay(100); digitalWrite(LED, HIGH); delay(100); }
as a test?
it works like a charm without blocking the flashing function, cool ^_^
include
define LED PB3
void setup(){ pinMode(LED, OUTPUT); }
void loop(){ digitalWrite(LED, LOW); delay(100); digitalWrite(LED, HIGH); delay(100); }
Tested above codes, no plus voltage observed at PB3 pin, by another words, if I do not want to use JTAG debugging function, how can I release the PB3 PB4 pin, etc? by google searching, I found this claimed to work on stm32 does not work with gd32 afio_cfg_debug_ports(AFIO_DEBUG_NONE)