Flash Programming on EVB08GB60 (newbee to flash)

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Flash Programming on EVB08GB60 (newbee to flash)

3,829 Views
JCC
Contributor I
Hello to all!
 
I am developping a project using the M68EVB08GB60 board  (MC9S08GB60  3L31R).
 
I have integrated Freescale's flash programming code as described in the HS08 Reference Manual, into my project. This is the same code that is used in the Serial Monitor program. (FlashErase1, FlashProg1, DoOnStack, & SpSub)
 
Every attempt to program a byte or several bytes into the lower flash addresses (1080 to 17FF) has failed. I have check the code against the monitor code for errors, all is good. I have single stepped the code to make sure that data and address were in thier proper places.
 
I am running with a 4Mhz crystal and a 20Mhz buss with FDIV set at 192Khz. System configuration is identical to the monitor (Monitor has been removed and the Flash unsecured)
 
The funny part (I'm not laughing) is that no errors are flagged. The routines terminate with A holding a copy of FSTAT shifted left 2 bits which would put FVIOL & FACCERR at bits 7 & 6 repectively but A reads 0.
 
Help!
 
JC
Labels (1)
0 Kudos
12 Replies

744 Views
peg
Senior Contributor IV
Hi JB,

You say you are having trouble programming flash in the small block in this device. Does this mean that you can successfully programme in the main large block of flash? Or are you not able to programme any of the flash?

0 Kudos

744 Views
JCC
Contributor I
Hello Peg!
 
Currently the high Rom (182C to 2FFF) is occupied. I will try moving the Flash Page to somewhere in the 3FFF region and see what happens. I will post the results.
 
A question: The manual states that the Flash is divided into 512 byte pages starting at address $1000. Does that mean that the first page that is usefull starts at $1200? (since RAM occupies locations $1000 to $107F). I am presently attempting to erase and write starting at $1080.
 
Since it was a simple matter, I ORG'd to $1200, that didn't change anything.
 
Thank you for responding,
 
JC
0 Kudos

744 Views
peg
Senior Contributor IV
Hi JC,

I don't definately know the answers here but would assume that the first page in this block is just a partially implemented and that you can page erase it just use an address actually implemented.
I just thought it best to avoid this area altogether until you get it working in the main block. Perhaps there are some special considerations when using this area.

0 Kudos

744 Views
JCC
Contributor I
Hi Peg & Mac
 
Problem solved. You can't execute Flash routines while the debug board is connected (OSBDM08), they just don't work.
 
Since the data I'm saving in Flash is used to initialise a block of RAM after reset, I was able to confirm that the data is written properly. I also powered down my board for 2 minutes just in case. The RAM was properly initialised.
 
I don't know if this problem is is isolated to the OSBDM board, or applies to the other tools also.
 
Thank you both again for your help,
 
Sincerely,
 
JC
0 Kudos

744 Views
peg
Senior Contributor IV
Hi JC,

Glad you found your problem!
I believe this is because you were viewing some portion of flash in a memory window within the debugger.
The BDM module in this case will be reading flash so the debugger can display it (via your OSBDM). These reads from the BDM disturb the flash programming. It can cause all sorts of problems. I believe you can either close the memory window or point it at ram or stop the periodic refresh. This way you can leave the OSBDM connected and the debugger running.

0 Kudos

744 Views
peg
Senior Contributor IV
Hi again JC,

I modified a emulated EEPROM test programme that I had written for the QG to run on the GB/GT.
I have attached it here.
After a quick check I found that it works OK except when trying to use the partial page that starts at $1080.
I have attached the code here.
You can see at the top where you can uncomment various addresses for the EEPROM buffer.
It works at the other 3 addresses tried here but jumps off into the weeds if you try it at $1080.
Did you get your code working at $1080 or leave it at $1200?

0 Kudos

744 Views
JCC
Contributor I
Hi Peg!
 
Thanks for the tip on using BDM with flash routines, didn`t think of that.
 
I have it working at 1080 with at least 21 bytes programmed.
 
I will try shutting down the memory window, write to Flash, and then call up the memory window again. I`ll let you know the results.
 
JC
0 Kudos

744 Views
peg
Senior Contributor IV
Hi JC,
Good, you got it figured out.
I found the problem with my testing.
I assumed I had placed my code at the beginning of the large flash block, but it was at the start of the small block. So I was erasing the code when I tried EEPROM at $1080.
Now that I changed the ORG it works at $1080 as well.


0 Kudos

744 Views
bigmac
Specialist III
Hello JC,
 
At risk of stating the obvious, but do you erase each sector before attempting to program bytes within the sector?  If so, you might check to see whether the erase process does succeed (all bytes read as 0xFF).
 
Regards,
Mac
 
0 Kudos

744 Views
JCC
Contributor I
Thank you Mac for responding so quickly. Yes I execute the FlashErase1 routine first, plus this area of flash has never been programmed so all bytes read FF. I am using the OSBDM08 board for debugging.
 
JC
0 Kudos

744 Views
bigmac
Specialist III
Hello JC,
 
I assume the values held in H:X and in ACC, immediately before FlashProg1 is called, are the appropriate ones.
Perhaps you could check that you actually have the intended bus frequency of 20MHz.
FCDIV register can only be written once out of reset - I assume you are writing all bits simultaneously.
 
Regards,
Mac
 
0 Kudos

744 Views
JCC
Contributor I
Hello Mac,
 
Yes. I have listed below the lines from the configuration code:
 
  ;  System clock initialization
        mov     #%01111000,ICGC1         ;sets buss at 20Mhz                                     
        mov     #%00110000,ICGC2         ;for 4Mhz crystal                             
        brclr   LOCK,ICGS1,*
  ; ### Init_FLASH init code
        ; FCDIV: DIVLD=0,PRDIV8=1,DIV5=0,DIV4=0,DIV3=1,DIV2=1,DIV1=0,DIV0=0
        LDX     #(mFPVIOL+mFACCERR)  ;added as a precaution
        STX     FSTAT
        LDX     #$4C
        STX     FCDIV                  ; Set clock divider
 

 As for the missing error flags, I spotted this thread:
 
 
JC
0 Kudos