WRE> Where is the subroutine 'AckCOP' located? Does this call use
WRE> absolute rather than relative addressing? Is the subroutine located
WRE> in a common page?
AckCOP is also in RAM (at $30CE). FLASH routines located from $3625.
AckCOP: movb #$55,ARMCOP
movb #$AA,ARMCOP
rts
>>I am working the MC9S12KG256 and writing flash driver
to program
>>CPU. Code executed from RAM.
WRE> [snip]
>>ExecFLASHCmd: ; C set on error
>> movb #%10000000,FSTAT
>>EFC_Wait: jsr AckCOP
>> brclr FSTAT,#%10000000,EFC_Wait
>>ChkFLASH: pshb
>> ldab FSTAT
>> andb #$30
>> addb #$FF
>> pulb
>> rts
>>
>>WaitFLASHCmd: ; C set on error
>> jsr AckCOP
>> brclr FSTAT,#%1000000,WaitFLASHCmd
>> bra ChkFLASH
WRE> [snip]
-- Sergey
Reply by "William R. Elliot"●March 26, 20102010-03-26
Where is the subroutine 'AckCOP' located? Does this call use
absolute rather than relative addressing? Is the subroutine located
in a common page?
Bill
At 12:52 PM 3/26/2010, you wrote: >Hi,
>
>I am working the MC9S12KG256 and writing flash driver to program
>CPU. Code executed from RAM.
[snip] >ExecFLASHCmd: ; C set on error
> movb #%10000000,FSTAT
>EFC_Wait: jsr AckCOP
> brclr FSTAT,#%10000000,EFC_Wait
>ChkFLASH: pshb
> ldab FSTAT
> andb #$30
> addb #$FF
> pulb
> rts
>
>WaitFLASHCmd: ; C set on error
> jsr AckCOP
> brclr FSTAT,#%1000000,WaitFLASHCmd
> bra ChkFLASH
[snip]
Reply by serg...@mail.ru●March 26, 20102010-03-26
Hi,
I am working the MC9S12KG256 and writing flash driver to program CPU. Code
executed from RAM.
FLASH memory is fully unsecured, FPROT for bank 0 is $84, for bank 1 is $FF.
Call to EraseFL (B=$00,A=$00) succesfully erases all FLASH sectors except
protected.
Call to WriteFL succesfully program only bank 0. For bank 1 it doesn't
return any error on programming stage, but there is no data programmed, so
comparsion always failed.
Is it my fault or i miss something from datasheet?
ldx PgmPtr
ldy PgmAddr
clra
WriteFL_CLoop: ldab a,x
cmpb a,y
bne WriteFL_CErr
inca
cmpa #$40
blo WriteFL_CLoop
clrb
rts
WriteFL_Err: ldab FSTAT
orab #$01
rts
WriteFL_CErr: ldab #$CE
rts
I am trying to write a routine that will
program flash bytes at the security location in fixed memory at location
$ff00. The flash is unsecured (FSEC = 0xfe) All the code is executed
from RAM. The first thing I want to do is erase the sector with command
$40. The FCLKDIV is set to program at just under 200khz, PVIOL and
ACCERR is checked for all banks, the bank is reset to bank 0 (FCNFG = 0)
the sector address is sent by writing something to $fe00, then the
command to erase the sector is sent (0x40 to FCMD). But as soon as that
is done, the ACCERR is set in the FSTAT register. I can't understand
why, this is a valid command and all the other conditions seem to be OK.
Does anyone have any insight on this?, thanks in advance. Oh, and PPAGE
is $3f, but the doc says it doesn't matter when programming fixed
memory.