Clearing PHSA and PHSB with LONGFILL?
JonnyMac
Posts: 9,530
in Propeller 1
I've got some dirt-simple code that is running in a "background" cog; part of that code reads two pots through a standard RC circuit. The background loop runs every millisecond, so I use a timer variable to keep track of the RC state.
This works:
After looking at it a while I thought I could shave off a couple instructions by changing the milddle section to this:
No bueno, and I cannot sort out while. $1FC is the address of phsa in a cog, right? (I did confirm that in the data sheet).
It's been a long day for me, and I've probably overlooked something simple, but it would be nice to know what that is.
This works:
pri measure_pots ' call only from support()
if (pottimer == 0)
dira[L_VOL..R_VOL] := %11 ' charge caps
elseif (pottimer == 2)
phsa := 0
dira[L_VOL] := 0
phsb := 0
dira[R_VOL] := 0
elseif (pottimer == 4)
lvolpot := (0 #> ((phsa >> 4) - 37) <# 400) >> 2 ' scale results, 0..100
rvolpot := (0 #> ((phsb >> 4) - 37) <# 400) >> 2
if (++pottimer => 5)
pottimer := 0
After looking at it a while I thought I could shave off a couple instructions by changing the milddle section to this:
elseif (pottimer == 2) longfill($1FC, 0, 2) dira[L_VOL..R_VOL] := %00
No bueno, and I cannot sort out while. $1FC is the address of phsa in a cog, right? (I did confirm that in the data sheet).
It's been a long day for me, and I've probably overlooked something simple, but it would be nice to know what that is.

Comments
Hope you had a good snooze, btw.