Skip to content

PA13 used as USR_SW conflicts with SW debug #1

Description

@dpgeorge

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.

Activity

  1. iabdalkader commented on Jan 4, 2014

    @iabdalkader

    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

  2. hagenkaye commented on Jan 6, 2014

    @hagenkaye

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions