Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PA13 used as USR_SW conflicts with SW debug #1

Open
dpgeorge opened this issue Jan 2, 2014 · 2 comments
Open

PA13 used as USR_SW conflicts with SW debug #1

dpgeorge opened this issue Jan 2, 2014 · 2 comments

Comments

@dpgeorge
Copy link
Member

dpgeorge commented Jan 2, 2014

Originally opened by @jevers76: When the software initializes PA13 as an input for USR_SW it's use as SWDIO ends. The chip must be erased before SW debbug can be used again. This makes debugging with a jtag or SW like the stlink 2 difficult. Can the PCB be changed? One alternative to changing the PCB would be to only init the pin when needed by calling some py function.

@iabdalkader
Copy link

Hi, there's a bit you can check to see if the debugger is attached, maybe something like this can be used as a workaround:

if (CoreDebug->DHCSR & CoreDebug_DHCSR_C_DEBUGEN_Msk) {
    //configure PA13 for SWD
    GPIO_InitTypeDef GPIO_InitStructure;
    GPIO_InitStructure.GPIO_Pin = PYB_USRSW_PIN;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
    GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
    GPIO_Init(PYB_USRSW_PORT, &GPIO_InitStructure);
    GPIO_PinAFConfig(PYB_USRSW_PORT, PYB_USRSW_PIN, GPIO_AF_SWJ);
} else {
    //use PA13 as user switch
    sw_init();
}

I tried it and it kinda works, but it needs some delay for the debugger to be detected...

See:
http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.faqs/ka14536.html

@hagenkaye
Copy link

It would be nice if the switch was moved to another pin.

I was inspired by your post. So I dug up my bus pirate and thought - "gee I wonder if I can use it to debug the micro python board". After some fiddling, I got debugging to work.

Pins needed by bus pirate to run as a jtag debugger

PA13 - TMS
PA14 - TCK
PA15 - TDO
PB3 = TDI

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants