ROM routines + 908QT2

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

ROM routines + 908QT2

2,154 Views
RChapman
Contributor I
This message contains an entire topic ported from a separate forum. The original message and all replies are in this single message. We have seeded this new forum with selected information that we expect will be of value to you as you search for answers to your questions.
 
Thu Sep 22, 2005 8:03 pm    
 
Hey all.

Has anyone successfully used the ROM-resident routines in a 908QT2 MCU? I've done all my development with a DEMO908QB8 board, using the AN2635 as a reference for the ROM routine locations, and using AN2504 and the Metrowerks programming API. Wonderful tools, I might add, with the exception of one error in the API (MASS bit mask was wrong).

I got all three of the functions I needed working on the Demo board - ReadRange, ProgramRangX, and ErasePageX.

In porting this code into my target MCU, a 908QT2, I've been unable to get the ROM routines to work. I've updated the initialization (ROM routine locations are the same) for the new target, using FAQ-20979 and AN2346. It's difficult since there is no way to debug my target code on this MCU. But I've narrowed it down. My program never returns from the ROM subroutines. This has got to be setup, right?

Key differences (that I can find) between the QB8 and QT2 are:

memory map and size, obviously
CPUSPD value ($04 on the QB8, $13 on the QT2)

Is there something else I'm missing?
 
Posted: Sat Sep 24, 2005 7:03 am    
 
I have successfully used the ERARNGE ($2806) and PRGRNGE ($2809) ROM-resident routines for the QT/QY series. I initially used AN2346 for ideas, but found these routines more complex than were necessary for my intended application. So the adapted routine that resulted will erase the first page (64 bytes) of flash, and then program up to 32 bytes. This is satisfactory for small amounts of data that only need to change a few times, so flash endurance is not a problem.

For the code shown below, I have defined the R0M routine locations, plus the following registers within an include file:

CTRLBYT EQU RAM+8
CPUSPD EQU RAM+9
LADDR EQU RAM+10
FLBPR EQU $FFBE

Here is the code for the sub-routine. Note that interrupts must be re-enabled because ERARNGE disables them.

; GENERAL EQUATES:
PBLOCK EQU FLASH ; Non-volatile block for data
DATSIZE EQU 2 ; Data bytes to be stored (up to 32)
FLBPRVAL EQU {(FLASH-$C000)/$40+1} ; Unprotect first block
SPDVAL EQU 13 ; ~(3.2 * 4) for 3.2MHz bus

***********************************************************
* ERASE FLASH PAGE & WRITE BLOCK
***********************************************************
; On entry, data to be written must reside in RAM, starting at RAM+12.
; RAM+8 through to RAM+11 will be over-written.
; On exit, CF = 1 if programmed data is verified, otherwise CF = 0

WRBLOCK:
MOV #SPDVAL,CPUSPD
CLR CTRLBYT ; Page erase only
LDHX #PBLOCK
LDA #DATSIZE
PSHX
ADD 1,SP ; Add LS address
DECA ; Last position in block
TAX
STHX LADDR
PULX
JSR ERARNGE ; Erase range - disable interrupts
LDHX #PBLOCK
JSR PRGRNGE ; Program block
CLI ; Re-enable interrupts
RTS

***********************************************************
ORG FLBPR ; Flash block protect register
DB FLBPRVAL ; First flash block unprotected

I hope this helps with your problem.

Regards,
Posted: Mon Sep 26, 2005 11:28 pm    
 
Thanks a bunch! I'll study your assembly and compare it with my C code. There's got to be some significant difference. Stay tuned...
 
Posted: Fri Oct 21, 2005 5:11 pm    
 
Well, I found out what was wrong with my code. It was the RDVRGNG routine that my program never returned from on my QT2/4 target. Yet RDVRGNG works on my QB8 DEMO board.

Apparently the ROM routine in this latest QT mask is different in how it fills up the RAM with Flash data. Both ERARNGE and PRGRNGE are working fine for me. I've replaced the RDVRGNG with my own routine to retrieve the flash data into local RAM.

I wonder if the location in ROM for RDVRGNG is different now, or just radically structured differently?
Labels (1)
0 Kudos
0 Replies