cancel
Showing results for 
Search instead for 
Did you mean: 

stm32 MCU download Application

huarui lin
Associate
Posted on November 17, 2017 at 09:45

Hi,everyone!

I did a stm32f103 firmware download application run on Windows system recently,and I found that there is about 1% of MCU can not download success and can not download again.Following is part of my code,hope that you can point my code bug out:

   

char

g_szPrgBoard[

50

]

=

'ST-LINK'

;

char

g_szPrgProtocol[

50

]

=

'SWD'

;

char

g_szPrgDevice[

50

]

=

'STM32F103x8'

;

char

g_szPort[

50

]   

=

'USB'

;

char

ProgMemFileName[_MAX_PATH]

=

'tx.hex'

;

char

OptionMemFileName_off[_MAX_PATH]

=

'103_protect_off.hex'

;

char

OptionMemFileName_on[_MAX_PATH]

=

'103_protect_on.hex'

;

unsigned

char

dOpttemp_on

=

0

,dProtemp

=

0

,dOpttemp_off

=

0

;

if

(

SetProgrammingConfiguration

(g_szPrgBoard,g_szPrgProtocol,g_szPrgDevice,g_szPort)

==

TRUE

){

ESetPreferences

(PROTECTION_WARNING,

FALSE

);

        

if

(

LoadFile

(OptionMemFileName_off,

'OPTION BYTE'

)

!=

TRUE

){

             dOpttemp_off

=

1

;

         }

        

if

(

Program

(

'OPTION BYTE'

)

!=

TRUE

){

dOpttemp_off

=

1

;

         }

        

if

(

Erase

(

'PROGRAM MEMORY'

,g_szPrgDevice)

!=

TRUE

){

             dProtemp

=

1

;

         }

if

(

FillImageMemory

(g_szPrgDevice,

'PROGRAM MEMORY'

)

!=

1

){

dProtemp

=

1

;

        

if

(

LoadFile

(ProgMemFileName,

'PROGRAM MEMORY'

)

!=

TRUE

){

dProtemp

=

1

;

}

SetByteInImageMemory

(g_szPrgDevice,

'PROGRAM MEMORY'

,

0x800F020

,

0x05

);

SetByteInImageMemory

(g_szPrgDevice,

'PROGRAM MEMORY'

,

0x800F030

,

0x02

);

SetByteInImageMemory

(g_szPrgDevice,

'PROGRAM MEMORY'

,

0x800F040

,

0x05

);

if

(

Program

(

'PROGRAM MEMORY'

)

!=

TRUE

){

dProtemp

=

1

;

         }

        

if

(

Verify

(

'PROGRAM MEMORY'

)

!=

TRUE

){

dProtemp

=

1

;

         }

ECloseComm

();

}

0 REPLIES 0