cancel
Showing results for 
Search instead for 
Did you mean: 

SWD floats, STM32F2, code don't run

vindhyachal
Associate II
Posted on August 13, 2015 at 08:39

1. I am using STM32F205, with serial wire debug, composing reset, clk, data & gnd pins.

2. Whenever I connect debugger my code runs perfectly. But without debugger, sometimes code just don't run. I am toggling a pin which never happens. it happens only sometimes.

3. No other clk init is done, so default 16Mhz clck, as soon as MCU power up, I keep on toggling pin. No code in between so couldn't be memory access other or anything. So pin toggle.

3. I have 0.1uf cap on reset pin & 10k pull down on boot pins.

4. However I have left swclk & swdata pins float.

5. I had checked below link & connected 10k pull down to clk & 10k pull-up to data.

http://support.code-red-tech.com/CodeRedWiki/HardwareDebugConnections

6.Code is running now. I will check multiple times before reaching conclusion, but any idea on this.

#wait-for-you--clive1-!-!-! #wait-for-you--clive1-!-!-!
17 REPLIES 17
vindhyachal
Associate II
Posted on August 16, 2015 at 20:01

1. Here it schematic, I have my own custom board.

http://docdro.id/z7owNme

2. Today I have problem in other board. Code does not run. Because as soon as code enters into systeminit(), I pulled a pin low. Since this never happens, that means code never enter to execute.

3. Checked voltage levels with CRO , directly on MCU pins 

Reset pin = 3.3 V

CLK = 0V

Data = 3.3V

BOOT0 = 0V

All AVDD & DVDD = 3.3V 

4. Also checked continuity by multimeter of various connections to check dry solder, but all are ok.

5. Issue is code never starts to execute.?

vindhyachal
Associate II
Posted on August 16, 2015 at 20:03

Edit: Didn't tey 10k pullup on reset pin, since no place in hardare. Can solder to check.

Boot0 is directlty grounded.

Problem arises only once in while. Say 1 in 100 times.

Posted on August 16, 2015 at 21:03

Is there some value to enumerating your answers?

What code exactly are you running, perhaps there's an issue with that? Does it run under the debugger?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on August 16, 2015 at 21:05

You said you pull the boot pins low, BOOT1 (PD2) really needs a pull-down on it.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
vindhyachal
Associate II
Posted on August 17, 2015 at 10:49

1. Yes code always run on debugger. no problem ever. I am using keil ulink2.

2. I have 10K pull-down resistor on boot0 pin.

You said ''

BOOT1 (PD2) really needs a pull-down on it.

''

But datasheet says if boot0 is pulled low, then boot1 is don't care for executing code from flash.

Also I had made this pin as GPIO_ANALOG as this is unused

3. As I have told that as soon as I enter the code, I make pin toggle with a timer.

Since this never happens when problem arises, that mean code never start to execute.

Even if reset is high 3.3V, all vdd = 3.3V, boot0 is low.

Posted on August 17, 2015 at 14:07

I'm leaning towards an issue with the crystal or the code. Marginal, or slow to start.

I'd probably instrument the code more tightly from the reset handler, to the point where the timer is configured.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
vindhyachal
Associate II
Posted on August 22, 2015 at 11:05

1. There is no external crystal. I use internal 16Mhz crystal which then use PLL for 120Mhz.

2. I had given some delay(50ms) between power up & pll setup. System worked for sometime.

But again sometimes problem arises

3. Parts of my code are:

Reset_Handler    PROC

                 EXPORT  Reset_Handler             [WEAK]

IMPORT  SystemInit

IMPORT  __main

                 LDR     R0, =SystemInit

                 BLX     R0

                 LDR     R0, =__main

                 BX      R0

                 ENDP

void SystemInit(void)

{

    initialize_unused_pins();

    configure_general_timer();

    configure_pll();

}

Posted on August 22, 2015 at 16:29

Not sure I can do much with that amount of information. Your going to need to look at how to effectively instrument and debug your own code.

I will note that when SystemInit() is call the C Runtime environment has not been initialized, so you'll need to watch what static variables and assignments are being used.

SystemInit() really just needs to enable the clocks and external memory interfaces.

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