Many of our customers usually consider choosing cost-effective chips under the premise of performance guarantee when selecting MCU microcontrollers for products.
Geehy APM32F003 series MCU is a 32-bit Arm® Cortex® M0+ core, power supply voltage 2.0~5.5V, up to 32K flash, up to 4K RAM, cost-effective single-chip microcomputer, the minimum power consumption is about 3.4ua, widely loved by the market.
At present, there are scenarios where customers need to use JTAG SWDIO SWCLK (corresponding pins PD1 and PD2) as GPIO ports in the process of customer development, but the feedback cannot output high and low status normally.
Check the user manual and suggest to configure PD1 and PD2 as normal IO, you need to set the register JTAGDIS to 1.
JTAG interface JTAGwInterfacewDisable
0: Enable JTAG interface; PD1 is SWDIO PD2 is SWCLK
1: Disable JTAG interface; PD1 and PD2 are common IOs
void GPIO_EnableSWD(void)
{*(uint8_t *)(GPIOD_BASE + 0x100) = 0x00;}
void GPIO_DisableSWD(void)
{ *(uint8_t *)(GPIOD_BASE + 0x100) = 0x01;}
So I will share with you a test code of the development board using APM32F003F6P6 as follows:
int main(void)
{
GPIO_Config_T gpioConfig;
/*** Turn off the SWD download function, Or set the PD1 and PD2 pin to normal IO port mode, it will not be able to Debug ***/
GPIO_DisableSWD();
/** PD1 and PD2(SWD) GPIO configuration */
gpioConfig.mode = GPIO_MODE_OUT_OD;
gpioConfig.pin = GPIO_PIN_1 | GPIO_PIN_2;
gpioConfig.speed = GPIO_SPEED_10MHz;
GPIO_Config(GPIOD, &gpioConfig);
while(1)
{
/*** Connect the PD1 and PD2 pin to LED light, and the LED light status will be reversed. ***/
GPIO_Toggle(GPIOD, GPIO_PIN_1 | GPIO_PIN_2);
Delay();
}
}
Then it can be used normally, but it should be noted that after SWD is disabled, it will not be able to download and Debug normally again!!!
https://github.com/GeehySemi/SWDIO-and-SWCLK-as-GPIO-ports/tree/main
Comments
Please log in or sign up to comment.