cancel
Showing results for 
Search instead for 
Did you mean: 

stlink/v2 debugger unable to connect

lakshmikantha85
Associate II
Posted on November 23, 2011 at 15:29

Hi,

I am unable to connect the stlink debugger using stlink utility program. My board contains stm32f103ZET6 controller, 512KB flash, 2K per page,

I am unable to read device information.

But i am able to connect my other board with stm32f103R8T6 to stllink debugger and able to flash and debug,

I am using 5 JTAG pins for IO purpose,

to enable and disable JTAG i am using PC13 as select jumper to switch between JTAG and IO using following code logic,

        GPIOC->CRH &= 0xFF0FFFFF; //PC13 for enable/disable JTAG (FACTORY SETTING)

        GPIOC->CRH |= 0x00400000;

        if((GPIOC->IDR &= 0x2000) == 0)

        {

        AFIO->MAPR &= 0xFBFFFFFF;

        while(1);                          

        }

        else

        {

        AFIO->MAPR |= 0x04000000;

        }

I am able to flash the program and work with my application correctly using H-Flasher,

I have to fine tune my code, so i need to connect debugger,

i am unable to do it.

PLs give me suitable solution
1 REPLY 1
Posted on November 23, 2011 at 16:18

if((GPIOC->IDR &= 0x2000) == 0)

Check the '&=', that probably shouldn't be there

if((GPIOC->IDR & 0x2000) == 0)

You might also consider that the ST-LINK is quite prone to connection issues, especially if you use DMA.

Also look if you are doing anything to the GPIO's hw/sw prior to this.

Need to debug the code behaviour, or confirm it's doing what you expect with your PC.13 pin check, then add some code to output status info out the serial port to a console.

        GPIOC->CRH = (GPIOC->CRH & 0xFF0FFFFF) | 0x00400000; //PC13 for enable/disable JTAG (FACTORY SETTING)

        // brief settle delay

        if((GPIOC->IDR & 0x2000) == 0)

        {

        AFIO->MAPR &= 0xF8FFFFFF; // Default JTAG enable '000'

        while(1); // honey-trap for debugger to sit in

        }

        else

        {

        AFIO->MAPR = (AFIO->MAPR & 0xF8FFFFFF) | 0x04000000; // '100' JTAG-DP & SWD-DP Disabled

        }

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..