MB95F718m

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

Hello,

can any one provide the example  software for sector erase suspend command?

my requirement is to Erase a half of the sector and remaining data should not effect by using erase operation.

for example: I want to erase sector SA2 from 0x2000 to 0x4000 only.

But when am using the sector erase command the total sector is erased.

So any one help me for the same.

Thanks

Anil

0 Likes
1 Solution
ChaoHaiM_11
Employee
Employee
25 replies posted 10 sign-ins 5 sign-ins

Hi Anil,

Sorry, we have not the flash operation example project of MB95F718.

I enclose code snippets from other series for your reference.

  .SECTION ERASECODE, CODE

  .EXPORT _EraseStart

;+++++++++++++++++++++++++++++++++++++++

; Command_Process

;  Flash Erase

; IN : EP : Erase Address

; OUT : A  : Return Flag

; 0 : Successed

; 1 : Fail

;+++++++++++++++++++++++++++++++++++++++

_EraseStart:

MOVW A,EP

PUSHW A ; Save write address

SETB 72H:1 //FSR:WRE

MOVW A,#0xF000

ANDW A

MOVW A,#0x0AAA

ORW A

MOVW EP,A ; 0x0AAA | (address & 0xf000)

XCHW A,T

MOVW A,#0x0554

ORW A

MOVW IX,A ; 0x0554 | (address & 0xf000)

MOV A,#0xAA ; 0x*AAAH <= 0xAA

MOV @EP,A

MOV A,#0x55 ; 0x*554 <= 0x55

MOV @IX,A

MOV A,#0x80 ; 0x*AAAH <= 0x80

MOV @EP,A

MOV A,#0xAA ; 0x*AAAH <= 0xAA

MOV @EP,A

MOV A,#0x55 ; 0x*554 <= 0x55

MOV @IX,A

POPW A ; Restore Erase address

MOVW EP,A

MOV A,#30H ; The last data.

mov @EP,A ; Start Erase

NOP

NOP

// clear watchdog

MOV 0CH, #0x35

EraseDQ3:

MOV A,@EP

AND A,#0x08 ; Check DQ3 ?

BZ EraseDQ3

EraseLoop:

BBS 72H:4,EraseEnd //FSR:RDY

// clear watchdog

MOV 0CH, #0x35

MOV A,@EP

AND A,#0x20 ; Check DQ5?

BZ EraseLoop

BBS 72H:4, EraseEnd //FSR:RDY

NOP

BBS 72H:4, EraseEnd //FSR:RDY

EraseError:

MOV A,#0xF0

MOV 0xFF00,A ; Reset Flash

MOV A,#01H ; Set error Flag

CLRB 72H:2

RET

EraseEnd:

CLRB 72H:2

MOV A, #0X00

RET

/*********************************************************************************************/

/*Module name:   Flash_Erase                                                                 */

/*Function description: flash erasing operation                                              */

/*Return: 1--OK                                                                              */

/*        0--NG                                                                              */

/*********************************************************************************************/

unsigned char Flash_Erase(unsigned int Address, unsigned char Sector_Chip)

{

unsigned char temp;

address = Address;

SWRE0 = 0x3F;

WDTC = 0x35;// clear watchdog

#pragma asm

MOVW A, _address // set erase address

MOVW EP,A

CALL _EraseStart // Start erase subroutine

MOV _result,A // Reture the result for flash erase

POPW IX

#pragma endasm

return result;

}

View solution in original post

0 Likes
1 Reply
ChaoHaiM_11
Employee
Employee
25 replies posted 10 sign-ins 5 sign-ins

Hi Anil,

Sorry, we have not the flash operation example project of MB95F718.

I enclose code snippets from other series for your reference.

  .SECTION ERASECODE, CODE

  .EXPORT _EraseStart

;+++++++++++++++++++++++++++++++++++++++

; Command_Process

;  Flash Erase

; IN : EP : Erase Address

; OUT : A  : Return Flag

; 0 : Successed

; 1 : Fail

;+++++++++++++++++++++++++++++++++++++++

_EraseStart:

MOVW A,EP

PUSHW A ; Save write address

SETB 72H:1 //FSR:WRE

MOVW A,#0xF000

ANDW A

MOVW A,#0x0AAA

ORW A

MOVW EP,A ; 0x0AAA | (address & 0xf000)

XCHW A,T

MOVW A,#0x0554

ORW A

MOVW IX,A ; 0x0554 | (address & 0xf000)

MOV A,#0xAA ; 0x*AAAH <= 0xAA

MOV @EP,A

MOV A,#0x55 ; 0x*554 <= 0x55

MOV @IX,A

MOV A,#0x80 ; 0x*AAAH <= 0x80

MOV @EP,A

MOV A,#0xAA ; 0x*AAAH <= 0xAA

MOV @EP,A

MOV A,#0x55 ; 0x*554 <= 0x55

MOV @IX,A

POPW A ; Restore Erase address

MOVW EP,A

MOV A,#30H ; The last data.

mov @EP,A ; Start Erase

NOP

NOP

// clear watchdog

MOV 0CH, #0x35

EraseDQ3:

MOV A,@EP

AND A,#0x08 ; Check DQ3 ?

BZ EraseDQ3

EraseLoop:

BBS 72H:4,EraseEnd //FSR:RDY

// clear watchdog

MOV 0CH, #0x35

MOV A,@EP

AND A,#0x20 ; Check DQ5?

BZ EraseLoop

BBS 72H:4, EraseEnd //FSR:RDY

NOP

BBS 72H:4, EraseEnd //FSR:RDY

EraseError:

MOV A,#0xF0

MOV 0xFF00,A ; Reset Flash

MOV A,#01H ; Set error Flag

CLRB 72H:2

RET

EraseEnd:

CLRB 72H:2

MOV A, #0X00

RET

/*********************************************************************************************/

/*Module name:   Flash_Erase                                                                 */

/*Function description: flash erasing operation                                              */

/*Return: 1--OK                                                                              */

/*        0--NG                                                                              */

/*********************************************************************************************/

unsigned char Flash_Erase(unsigned int Address, unsigned char Sector_Chip)

{

unsigned char temp;

address = Address;

SWRE0 = 0x3F;

WDTC = 0x35;// clear watchdog

#pragma asm

MOVW A, _address // set erase address

MOVW EP,A

CALL _EraseStart // Start erase subroutine

MOV _result,A // Reture the result for flash erase

POPW IX

#pragma endasm

return result;

}

0 Likes