Boris-Chengbiao Zhou 1374c701ab hc32f460: Disable JTAG/SWD on pins so they can be used for GPIO/serial
This change is required to sucessfully use PA13/PA14 for UART. Otherwise
they function as SWDIO/SWCLK.

Relevant excerpt from the reference manual (translated):
The initial state of PA13, PA14, PA15, PB3, and PB4 ports is that the
JTAG/SWD function is valid after reset. When configuring FSEL[5:0] to
select the function, you need to write 0 to the corresponding bit of the
register PSPCR to invalidate the JTAG/SWD function.

Signed-off-by: Boris-Chengbiao Zhou <bobo1239@web.de>
2023-06-20 12:05:32 -04:00

35 lines
978 B
C

// Code to setup clocks on Huada HC32F460
//
// Copyright (C) 2022 Steven Gotthardt <gotthardt@gmail.com>
//
// This file may be distributed under the terms of the GNU GPLv3 license.
#include "autoconf.h" // CONFIG_MACH_AVR
#include "sched.h"
#include "system_hc32f460.h"
#include "hc32f460_gpio.h"
/****************************************************************
* Startup
****************************************************************/
// Main entry point - called from armcm_boot.c:ResetHandler()
void __attribute__((noreturn))
armcm_main(void)
{
// sets the system clock speed variable for library use
SystemInit();
// disable JTAG/SWD on pins PA13, PA14, PA15, PB3, PB4
// SWD still works until the relevant pins are reconfigured. Proprietary
// flash program (XHSC ISP) must be used to reflash afterwards.
PORT_DebugPortSetting(ALL_DBG_PIN, Disable);
// manage the system
sched_main();
// never get here
for (;;) ;
}