Problem
Armored Cars
Posts: 172
device sx52,oschs1
device turbo,stackx,optionx
IRC_CAL IRC_SLOW
reset RSPO
freq 50_000_000
org8
fsrcounter·ds·1
rcounter·ds·1
loop1var·ds·1
drag··ds·1
dloop1var·ds·1
dloop2var·ds·1
dloop3var·ds·1
dloop4var·ds·1
;
RESET POINT ONLY
RSPO
mov·!ra,#0
mov·!re,#0
;
IDLE
mov·$30,#%10000000
mov·$31,#%01000000
mov·$32,#%00100000
mov·$33,#%00010000
IdleLoop
mov·loop1var,#4········· ;right here the program goes back to RSPO and just loops
clr·rcounter
mov·FSR,#$2F
loop1
call·xaxis
inc·FSR
mov·re,IND
call·delay
clr·re
djnz·loop1var,loop1
jmp·IdleLoop
xaxis
call·xtable
mov·ra,w
ret
xtable
mov·w,rcounter
jmp·pc+w
retw·%01110111
retw·%10111011
retw·%11011101
retw·%11101110
retw·0
retw·0
delay
ret
Right at
mov·loop1var,#4
the program goes back to the reset point.· I can't figure it out.
device turbo,stackx,optionx
IRC_CAL IRC_SLOW
reset RSPO
freq 50_000_000
org8
fsrcounter·ds·1
rcounter·ds·1
loop1var·ds·1
drag··ds·1
dloop1var·ds·1
dloop2var·ds·1
dloop3var·ds·1
dloop4var·ds·1
;
RESET POINT ONLY
RSPO
mov·!ra,#0
mov·!re,#0
;
IDLE
mov·$30,#%10000000
mov·$31,#%01000000
mov·$32,#%00100000
mov·$33,#%00010000
IdleLoop
mov·loop1var,#4········· ;right here the program goes back to RSPO and just loops
clr·rcounter
mov·FSR,#$2F
loop1
call·xaxis
inc·FSR
mov·re,IND
call·delay
clr·re
djnz·loop1var,loop1
jmp·IdleLoop
xaxis
call·xtable
mov·ra,w
ret
xtable
mov·w,rcounter
jmp·pc+w
retw·%01110111
retw·%10111011
retw·%11011101
retw·%11101110
retw·0
retw·0
delay
ret
Right at
mov·loop1var,#4
the program goes back to the reset point.· I can't figure it out.
Comments
change
org8
into
org 8
rox on pal
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
engineer, fireman, bowler, father, WoW addict [noparse];)[/noparse]
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"SX-Video·Module" Now available from Parallax for only $28.95
http://www.parallax.com/detail.asp?product_id=30012
Product web site: www.sxvm.com
Available now... SX-Video OSD module $59.95 www.sxvm.com
"I'm a man, but I can change, if I have to, I guess"
Red Green
·
Bean is right, suggesting an ORG $0A instead of an ORG 8 because addresses 8 and 9 are reserved for the two addional I/O ports (RD, RE) on the SX52. But this also means that you only have 6 bytes of free memory in the global RAM space, instead of the 8 bytes, your program defines.
If you don't need ports RD and RE, simply configure both ports with all bits set for output. You may then use locations 8 and 9 as "regular" registers. I did this recently for testing a program designed for an SX20 on an SX52 Proto Board, and it worked as expected.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Greetings from Germany,
G
I do have another question though.· The register map (page 152 of the SX-Key Development System Manual) looks as if $00-$0F is the global, $10-$1F is bank 1, $20-$2F is bank 2 and ect.· From $10 on is general purpose memory.· For some reason I am thinking this is wrong because of the Exploring the SX Microcontroller book (I don't have it right now so I can't quote it).· It is something with the global that makes Bank 0 made up of$00-$0F (global) and $10-$1F (general purpose).· Bank 1 is made up of $20-$2F (global) and $30-3F (general) and so on.· Its a bit confusing and I'm not quite sure what is right.
You can only access that memory by setting FSR to 0 and using $10 thru $1F like:
CLR FSR
MOV $10,#$FF
this code...
MOV FSR,#$10
MOV IND,#$FF
will move the value into BANK 1 location 0
and this code
MOV FSR,#$0F
MOV IND,#$FF
will move the value into GLOBAL memory address $0F
If you notice in the debugger there is no BANK 0 either...
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"SX-Video·Module" Now available from Parallax for only $28.95
http://www.parallax.com/detail.asp?product_id=30012
Product web site: www.sxvm.com
Available now... SX-Video OSD module $59.95 www.sxvm.com
"I'm a man, but I can change, if I have to, I guess"
Red Green
·
The SX can only access 32 registers at one time. If you set FSR to $20 registers $10-$1F are different than if FSR was set to $40. $00-$0F is the same no matter what. Any register can be accessed by loading the location into FSR (ex: $37 or $5A). Registers can also be accessed by using the bank command (bank loop1var, clr loop1var)
Somebody please correct me if I'm wrong.
This brings up another question... What defines a bank? What is their signifigance?
It's like a 16 byte window, that is moved using FSR or BANK.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"SX-Video·Module" Now available from Parallax for only $28.95
http://www.parallax.com/detail.asp?product_id=30012
Product web site: www.sxvm.com
Available now... SX-Video OSD module $59.95 www.sxvm.com
"I'm a man, but I can change, if I have to, I guess"
Red Green
·
All the BANK command does is set FSR.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"SX-Video·Module" Now available from Parallax for only $28.95
http://www.parallax.com/detail.asp?product_id=30012
Product web site: www.sxvm.com
Available now... SX-Video OSD module $59.95 www.sxvm.com
"I'm a man, but I can change, if I have to, I guess"
Red Green
·
In this example
org $0A
loop1var ds 1
org 0
mov FSR,#$30
mov loop1var,#$FF
inc FSR
Does FSR now contain $0C or $31?
Also if a bank is a 16 byte window does that mean $20-$FF is general purpose?· By that I mean FSR can be set to any of those numbers and everything will be general purpose regeisters.· Or do the global registers carry over to some of those?
Sorry if this is frustrating you.· I just got noone to help me here (only one teacher here knows of assembly, but she took it in college and knows nothing of microcontrollers).· I am getting confused by the memory maps.· I attatched a pic of the two maps I have.