Search the web
Sign In
New User? Sign Up
vmu-dev · The VMU Development list
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Want your group to be featured on the Yahoo! Groups website? Add a group photo to Flickr.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
[vmu] VMU and Flash ROM...   Message List  
Reply | Forward Message #50 of 1156 |
[vmu] Re: VMU and Flash ROM...

Hello.

About my problem with not being able to correctly write to the Flash Rom,
here is some sample code. For reasons unknown to me, this one seems to
cause the program to _hang_ when calling the write_flash function, while
in the real program I'm working on it only seemed to refuse to write to
addresses not divisable by $100 (e.g. $180, $280 etc.).

Therefore I think I'm probably doing something _generally_ wrong (stupid
me). So, if someone could please explain to me *EVERY* step needed to
write to the Flash Rom, *IN DETAIL*, I would highly appreciate it...

BTW, people, when you post source code or new tricks, *PLEASE* add as many
comments as possible. Write down after each line of code what the given
command does, and why it needs to be done this way. Even though the code
may be perfectly obvious for you, for many others it is *NOT*. So for
God's sake, please _comment_ your stuff! I really can't point this out
often enough.

Ok, now let's get to the code sample. If anyone can show me what I'm
doing wrong, I would highly appreciate it:

------------------------------------------------------------------------


lev_offs_lo = $30 ; define variables to store address
lev_offs_hi = $31


[...]


.org $100

write_flash:
not1 ext,0 ; VMS Firmware call, "write Flash Rom"
jmpf write_flash
;
ret


[...]


start:
mov #$a1,ocr ; the usual program init stuff
mov #$09,mcr
mov #$80,vccr
clr1 p3int,0
clr1 p1,7
mov #$ff,p3
;
; ---------------------------------------------------------------
; fill Ram from $80 - $ff with %10101010 (test data to write)
; ---------------------------------------------------------------
;
mov #$80,1 ; we start at Ram location $80
mov #$aa,acc ; byte to write
.fill_block:
st @R1 ; write byte (@R0 & @R1 always access Ram half)
inc 1 ; increase pointer
ld 1
bnz .fill_block ; already 128 byte written?
;
; ---------------------------------------------------------------
; now write the test data to the Flash Rom
; ---------------------------------------------------------------
;
mov #<write_location,lev_offs_lo ; write-address in Flash (lo)
mov #>write_location,lev_offs_hi ; write-address in Flash (hi)
;
mov #4,c ; c = counter (we write 4 * 128 byte)
;
.write_next_part:
push 0 ; save what gets scratched by flash write
push b
push c
push trl
push trh
push xbnk
;
push ie
push ocr
;
clr1 ie,7 ; clear IE bit 7 (disable all interrupts)
mov #$81,ocr ; switch to 600 kHz when writing to Flash
;
mov #1,$7c ; set Finalize Flag (1 = wait indefinitely
; for last byte to stabilize)
ld lev_offs_lo
st $7d ; $7d = lo-offset current write-address
ld lev_offs_hi
st $7e ; $7e = hi-offset current write-address
mov #0,$7f ; $7f = 0 (24 bit big endian)
;
call write_flash ; write to Flash Rom
;
pop ocr
pop ie
;
pop xbnk ; restore what got scratched by flash write
pop trh
pop trl
pop c
pop b
pop 0
;
; ---------------------------------------------------------------
; add 128 to write address, so next chunk of data will be placed
; after the data we just wrote
; ---------------------------------------------------------------
;
ld lev_offs_lo
add #$80 ; add #$80 to lo-byte
st lev_offs_lo
ld lev_offs_hi
addc #0 ; add carry to hi-byte, if result > 255
st lev_offs_hi
;
dbnz c,.write_next_part ; already 4 * 128 byte written?
;
; ---------------------------------------------------------------
; now show what we wrote on the LCD screen
; ---------------------------------------------------------------
;
mov #<write_location,trl
mov #>write_location,trh
call setscr ; standard 'display screen' routine
; as found in "Tetris", "Bounce" etc.

[...]


.cnop 0,$80 ; address must be divisable by $80

write_location:
;
; 512 (4 * 128) byte to overwrite
;
.byte " "
.byte " "
.byte " "
.byte " "
.byte " "
.byte " "
.byte " "
.byte " "
.byte " "
.byte " "
.byte " "


------------------------------------------------------------------------

Bye


Alesssandro
---
You get what anyone gets. You get a lifetime.



Tue Mar 7, 2000 2:26 am

tyro@...
Send Email Send Email

Forward
Message #50 of 1156 |
Expand Messages Author Sort by Date

Hello. I'm currently writing a program where I need to write data to the VMU Flash Rom. Only problem, for some reason I can't write to addresses that are not...
Alessandro Sanasi
tyro@...
Send Email
Mar 6, 2000
1:15 am

... Alessandro> I'm currently writing a program where I need to write data to the VMU Alessandro> Flash Rom. Only problem, for some reason I can't write to...
Marcus Comstedt
marcus@...
Send Email
Mar 6, 2000
3:00 pm

Hello. About my problem with not being able to correctly write to the Flash Rom, here is some sample code. For reasons unknown to me, this one seems to cause...
Alessandro Sanasi
tyro@...
Send Email
Mar 7, 2000
2:25 am

Ok, I've spotted what you're doing wrong. Somehow, you seem to have misunderstood the concept of big-endianness. The _most_ significant part of the address...
Marcus Comstedt
marcus@...
Send Email
Mar 7, 2000
1:33 pm

... Aha, I see... (already found it out by myself, BTW). :) However, aren't word-values (16 bit), dword-values (32 bit) etc. always stored in memory with the...
Alessandro Sanasi
tyro@...
Send Email
Mar 19, 2000
10:23 pm

tyr-@... (alessandro sanasi) wrote: original article:http://www.egroups.com/group/vmu-dev/?start=80 ... always ... example, ... is it ... Well, it...
Marcus Comstedt
marcus@...
Send Email
Mar 26, 2000
9:28 pm
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help