pasm timing help
below is my code. I need some help calculating the timing.
my math says
ulOnTime must be set to 57 or greater
ulOffTime must be set to 9 or greater
if ulOnTime+ulOffTime is set to 1211 then rdword on line B will hit hub op on time
values on line A and C will correct for code exection time differences keeping ulOnTime and ulOffTime minimums at lowest possible value.
my math is wrong as the screen stays blank. I can make it work by using nop to waist cycles but i am trying to optimize for power consumption. Total execution must be less then 1/60 of a second at 80MHz I am sure 1211 is small enough to do that.
my math says
ulOnTime must be set to 57 or greater
ulOffTime must be set to 9 or greater
if ulOnTime+ulOffTime is set to 1211 then rdword on line B will hit hub op on time
values on line A and C will correct for code exection time differences keeping ulOnTime and ulOffTime minimums at lowest possible value.
my math is wrong as the screen stays blank. I can make it work by using nop to waist cycles but i am trying to optimize for power consumption. Total execution must be less then 1/60 of a second at 80MHz I am sure 1211 is small enough to do that.
DAT
org 0
'dira:=$03FF0000(4 cycles)
PDisplay mov dira,PINSDIR 'Set pins to output
'Update dimming values
:main rdword ulOnTime,pToScreenOn 'get on time
rdword ulOffTime,pToScreenOff 'get off time
'set X pointer to last column+1(8 cycles)
mov ulX,#60 'set to last column+1
mov pToX,pToDisplay 'set ptr to point to x value in ulDisplay
'setup counter (12 cycles)
mov ulCNTCheck,cnt 'set ulCNTCheck to current tim
add ulCNTCheck,ulOnTime 'add led on time
add ulCNTCheck,#22 'add offset for outer (26 for outer routine-4 for line after tjnz command looping to inner ---------------------------A-------------------
'move X pointer one column left(8 cycles)
:outer sub ulX,#1 'set to previous column
sub pToX,#2 'set ptr to point to x value in ulDisplay
'read column X fromDisplay(7 cycles + 3 from main, )
rdword ulColumn,pToX 'Read column ---------------------------B-------------------
'set Y pointer to last row+1(8 cycles)
mov ulY,#14 'Set to last row+1
mov ulMask,MASKSTART 'set to %1 0000000 0000000
'move Y pointer one row up(8 cycles)
:inner sub ulY,#1 'set to above pixel
shr ulMask,#1 'shift mask bit to match requested pixel
'See if pixel is on(16 if on,12 if off)
mov temp,ulColumn 'Copy ulColumn so data can be re used
and temp,ulMask 'Clear all bits but bit for this pixel
tjz temp,#:turnoff 'if pixel is off don't turn on
'Turn LED on(24 cycles)
mov temp,ulY 'Copy current Y value
shl temp,#6 'Shift Y to upper half of 10 bit address
or temp,ulX 'Add current X value
shl temp,#16 'Shift to match output pins
mov outa,temp 'turn led on
'set duty cycle
:turnoff waitcnt ulCNTCheck,ulOffTime 'wait until on time over then add off time to ulCNTCheck
mov outa,LEDOFF
waitcnt ulCNTCheck,ulOnTime 'wait until off time over then add on time to ulCNTCheck
'do next row or next column
tjnz ulY,#:inner 'if not all leds in column done do inner over again
'do next column or start over
add ulCNTCheck,#27 'compensate for difference in inner ---------------------------C-------------------
tjnz ulX,#:outer 'if display not done do column to left
jmp #:main 'display done start over
'Locale Value
ulX long 0
ulY long 0
ulColumn long 0
ulMask long 0
ulCNTCheck long 0
pToDisplay long 0
pToX long 0
pToScreenOn long 0
pToScreenOff long 0
temp long 0
'Dimming X+Y must be less then 379
ulOnTime long 0 'ON=4+X
ulOffTime long 0 'OFF=13+Y
'constants
LEDOFF long $003F0000
PINSDIR long $03FF0000
MASKSTART long $4000
fit 496
