cancel
Showing results for 
Search instead for 
Did you mean: 

Can't debug code as all pin gets configured as analog mode

aamirali641989
Associate II
Posted on May 26, 2014 at 10:50

I am using STM32F205RBT6, Keil 4.73 & Ulink2 & SWD communication

I was trying some test codes for low power mode.

One of app note says to configure all inputs pins as analog mode, by first enabling the clock & then after configuring in analog mode disable the clock to all pins.

I have written my code at last. 

Now problem is since all pins gets configured including debug pins: SWCLK & SWDIO as analog. So first time I was able to debug the chip by loading code into it. 

But after that since pins gets configured so I am not able to debug/load code anymore.

Error message comes ''SWD communication failure.''

1. I have switched off power supply & then again switched on to check , but cannot do that.

2. I had forcefully put reset line low & then connect the debugger.

Error message comes:  ''Could stop Cortex M3 device, so check JTAG cable''

How to remove that problem. 

Application note : AN3430 by ST , Page 19

void main()

{

/* enable all peripherals clock */

    GPIOC_CLK_ENABLE();

    GPIOH_CLK_ENABLE();    

    GPIOA_CLK_ENABLE();

    GPIOB_CLK_ENABLE();

    GPIOD_CLK_ENABLE();

    

/* delay after enabling peripheral */    

    DELAY_AFTER_RCC_ENABLE();

    

/* Configure GPIO pins :   PC13 PC14 PC15 PC0 

                           PC1  PC2  PC3  PC4 

                           PC5  PC6  PC7  PC8 

                           PC9  PC10 PC11 PC12 */   

    GPIO_InitStructure.GPIO_Pin   =  GPIO_Pin_13|GPIO_Pin_14|GPIO_Pin_15|GPIO_Pin_0|GPIO_Pin_1|GPIO_Pin_2|GPIO_Pin_3|GPIO_Pin_4 

                                    |GPIO_Pin_5|GPIO_Pin_6|GPIO_Pin_7|GPIO_Pin_8|GPIO_Pin_9|GPIO_Pin_10|GPIO_Pin_11|GPIO_Pin_12;

    GPIO_InitStructure.GPIO_Mode  = GPIO_Mode_AN;

    GPIO_InitStructure.GPIO_PuPd  = GPIO_PuPd_NOPULL;

    GPIO_Init(GPIOC, &GPIO_InitStructure);   

    

/* Configure GPIO pins :   PH0 PH1 */   

    GPIO_InitStructure.GPIO_Pin   =  GPIO_Pin_0|GPIO_Pin_1;

    GPIO_InitStructure.GPIO_Mode  = GPIO_Mode_AN;

    GPIO_InitStructure.GPIO_PuPd  = GPIO_PuPd_NOPULL;

    GPIO_Init(GPIOH, &GPIO_InitStructure);      

/* Configure GPIO pins :   PA0  PA1  PA2  PA3 

                           PA4  PA5  PA6  PA7 

                           PA8  PA9  PA10 PA11 

                           PA12 PA13 PA14 PA15 */

    GPIO_InitStructure.GPIO_Pin   =  GPIO_Pin_13|GPIO_Pin_14|GPIO_Pin_15|GPIO_Pin_0|GPIO_Pin_1|GPIO_Pin_2|GPIO_Pin_3|GPIO_Pin_4 

                                    |GPIO_Pin_5|GPIO_Pin_6|GPIO_Pin_7|GPIO_Pin_8|GPIO_Pin_9|GPIO_Pin_10|GPIO_Pin_11|GPIO_Pin_12;

    GPIO_InitStructure.GPIO_Mode  = GPIO_Mode_AN;

    GPIO_InitStructure.GPIO_PuPd  = GPIO_PuPd_NOPULL;

    GPIO_Init(GPIOA, &GPIO_InitStructure);      

/* Configure GPIO pins :   PB0  PB1  PB2  PB10 

                           PB11 PB12 PB13 PB14 

                           PB15 PB3  PB4  PB5 

                           PB6  PB7  PB8  PB9 */

    GPIO_InitStructure.GPIO_Pin   =  GPIO_Pin_13|GPIO_Pin_14|GPIO_Pin_15|GPIO_Pin_0|GPIO_Pin_1|GPIO_Pin_2|GPIO_Pin_3|GPIO_Pin_4 

                                    |GPIO_Pin_5|GPIO_Pin_6|GPIO_Pin_7|GPIO_Pin_8|GPIO_Pin_9|GPIO_Pin_10|GPIO_Pin_11|GPIO_Pin_12;

    GPIO_InitStructure.GPIO_Mode  = GPIO_Mode_AN;

    GPIO_InitStructure.GPIO_PuPd  = GPIO_PuPd_NOPULL;

    GPIO_Init(GPIOB, &GPIO_InitStructure);   

/* Configure GPIO pins :   PD2 */   

    GPIO_InitStructure.GPIO_Pin   =  GPIO_Pin_2;

    GPIO_InitStructure.GPIO_Mode  = GPIO_Mode_AN;

    GPIO_InitStructure.GPIO_PuPd  = GPIO_PuPd_NOPULL;

    GPIO_Init(GPIOD, &GPIO_InitStructure);     

    

///* disable all peripherals clock */

    GPIOC_CLK_DISABLE();

    GPIOH_CLK_DISABLE();

   GPIOA_CLK_DISABLE();

    GPIOB_CLK_DISABLE();

    GPIOD_CLK_DISABLE();

6 REPLIES 6
os_kopernika
Associate II
Posted on May 26, 2014 at 11:59

@A2: You are a

http://www.keil.com/forum/57911/

.

aamirali641989
Associate II
Posted on May 26, 2014 at 14:00

Hi I have tried to debug by forcing reset pin low, but error ''

Could stop Cortex M3 device, so check JTAG cable

''

os_kopernika
Associate II
Posted on May 26, 2014 at 14:52

aamirali641989
Associate II
Posted on May 27, 2014 at 09:36

I have tried by pulling reset line low & kept reset line oen & start debugger at once, without any delay.

Now board had worked & I had removed that code.

But what happened I don't understand. 

If there is delay between rset low to open & debugging start, it doesn't work

chen
Associate II
Posted on May 27, 2014 at 13:07

''I was trying some test codes for low power mode.

One of app note says to configure all inputs pins as analog mode, by first enabling the clock & then after configuring in analog mode disable the clock to all pins.

I have written my code at last. 

Now problem is since all pins gets configured including debug pins: SWCLK & SWDIO as analog. So first time I was able to debug the chip by loading code into it. 

But after that since pins gets configured so I am not able to debug/load code anymore.''

You MUST NOT change the pins for SWD/JTAG if you expect to use a debugger!

It sounds like you have got you debugger/code working again.

Bear in mind that (technically) it is not possible to debug the processor in 'low power' mode, Sleep, Stop and Standby modes all stop clocking the ARM core. Once you stop clocking the ARM core - the clock for SWD/JTAG stops!

To get around this for 'low power' they simulate the low power modes ie the ARM core is still clocked but the status bits indicate that the processor is stopped.

Posted on May 27, 2014 at 15:51

http://www.keil.com/forum/57911/

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