PDA

View Full Version : slow spin



mctrivia
01-20-2009, 03:43 PM
I have built a 60x14 led display(840 pixels) with the following code there is a visible blink.




dira[25..16]~~
repeat
repeat ubVb from 0 to 13
outa[25..22]:=ubVb
Multi:=1<<ubVb
repeat ubVa from 0 to 59
if Long[@ulDisplay][ubVa]&Multi
outa[21..16]:=ubVa
else
outa[21..16]:=$3F




my math says 80MHz/60/840=1587 cycles per pixel to not blink. cant figure out how the interpreter could be that slow

Ale
01-20-2009, 05:05 PM
The interpreter uses around 80 cycles per opcode.

I'd recommend you use assembly for that or you split it across two COGs (with SPIN) but you may need to rewire part of your matrix. Asm is the way to go http://forums.parallax.com/images/smilies/smile.gif

hal2000
01-21-2009, 12:28 AM
ALE·is right.

ASM is the solution
Spin is·slow
Spin control is useful for processes that do not need speed

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Does the curiosity killed the cat?

mctrivia
01-21-2009, 09:09 AM
i seem to be having some trouble with the converting to ASM. I think I am making an error with the pointerX but not sure. wish we could use index reads.




DAT
ulDisplay long 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0


DAT
org 0

'Set Direction
Display mov dira,#PINSDIR

'Set to begining of dislay
:main mov ulY,#0 'zero ulY

'Initialize output to start processing row
:outer mov temp,ulY 'copy to temp
shl temp,22 'rotate to match output pins
or temp,#LEDOFF 'turn all leds off
mov outa,temp 'set output pins

'Set to begining of row
mov ulX,#0 'Set to first pixel of row
mov ptrToX,#ptrToDisplay 'copy display pointer

'Calculate pixel mask
mov ulM,#1 'Set ulM to 1
shl ulM,ulY 'Shift left to proper bit '

'Calculate if pixel is on or off
:inner rdlong temp,ptrToX
and temp,ulM
cmp temp,#0 WZ

'Calculate output state
mov temp,ulX
shl temp,16
if_z mov outa,#LEDOFF 'turn led off
if_nz or outa,temp 'turn led on

'Set for next pixel
add ulX,#1
add ptrToX,#1

'See if finished line
cmp ulX,#60 WZ
if_nz jmp #:inner

'See if finished display
add ulY,#1
cmp ulY,#14 WZ
if_nz jmp #:outer
jmp #:main


'Locale Time Value
ulX long 0
ulY long 0
ulM long 0
ptrToDisplay long 0
ptrToX long 0
temp long 0

'constants
LEDOFF long $003F0000
PINSDIR long $03FF0000
fit 496

Kye
01-21-2009, 11:47 AM
Okay, first #pinsdir produces the address of the variable, not the stuff in the variable, the same goes for the use of #Ledoff. Just use the name only to acess the stuff in the variable.

This problem is also present with #ptrToDisplay which again produces the address of the register in the cog's rams, not the stuff in the address.

Those are the biggest flaws I see in the code.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nyamekye,

Post Edited (Kye) : 1/21/2009 3:52:58 AM GMT

mctrivia
01-21-2009, 12:48 PM
i figuered out I had # n wrong places. # is used to read address of that variable or emediate value. I have fixed those errors below but it still does not work. Now for some reason every 4 pixels horizontally are identical to each other. asm did fix blinking image is solid.




DAT
org 0

'Set Direction
Display mov dira,PINSDIR

'Set to begining of dislay
:main mov ulY,#0 'zero ulY

'Initialize output to start processing row
:outer mov ulLineMask,ulY 'copy to temp
shl ulLineMask,#22 'rotate to match output pins

'Set to begining of row
mov ulX,#0 'Set to first pixel of row
mov ptrToX,ptrToDisplay 'copy display pointer

'Calculate pixel mask
mov ulM,#1 'Set ulM to 1
shl ulM,ulY 'Shift left to proper bit '

'Calculate if pixel is on or off
:inner rdlong temp,ptrToX
and temp,ulM
cmp temp,#0 WZ

'Calculate output state
mov temp,ulX 'Copy current X value
shl temp,#16 'Shift X value to align with output pins
or temp,ulLineMask 'Add Y portion
if_z mov outa,LEDOFF 'turn led off
if_nz mov outa,temp 'turn led on

'Set for next pixel
add ulX,#1
add ptrToX,#1



'See if finished line
cmp ulX,#60 WZ
if_nz jmp #:inner

'See if finished display
add ulY,#1
cmp ulY,#14 WZ
if_nz jmp #:outer
jmp #:main




'Locale Time Value
ulX long 0
ulY long 0
ulM long 0
ptrToDisplay long 0
ptrToX long 0
temp long 0
ulLineMask long 0

'constants
LEDOFF long $003F0000
PINSDIR long $03FF0000
fit 496