Simple code that won't work.
velocityxlrg
Posts: 18
Can someone help me figure out why this short bit of code won't work?
I'm trying to display a variable on the TV screen, pause 3 seconds,
then start an assembly cog to add one to the variable, wait 3 more seconds,
and display the new value.
I'm trying to display a variable on the TV screen, pause 3 seconds,
then start an assembly cog to add one to the variable, wait 3 more seconds,
and display the new value.
spin
730B
Comments
Also a DAT long is an inline data assignment, change memory to res 1.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.
rdlong temp,memory
should be: mov temp,memory
because during startup of the new cog the location "memory" has been copied to this cog's ram and
mov memory,PAR
refers to the cog "memory" location and not to the main memory location.
Christof
I do not have still [noparse]:([/noparse] my Propeller, so only is theory.
The TV screen displays the "variable=1234" then pauses 3 seconds.
The screen then gets some garbage characters then completely gets garbled up and quits.
I tried changing the DAT data assignment to memory RES 1, but that did not change anything.
I'm quite sure that when you "mov memory,PAR" you are only copying the main memory location to
the new cog's variable called memory. So to read the value store in the main memory at that location
you need to rdlong temp,memory which transfers a copy of the main memory content to the cog's
memory variable called temp. But I could be wrong - my code doesn't work!
Another thing I noticed. The TV base pin is 25. This needs to be a multiple of 4
as I understand it.
Good catch Mr. Green. The problem was that the cog wasn't stopping and must of been stomping
all over the memory. As far as I can tell, the TV base pin doesn't care about being a
multiple of 4 - I've had it in a number of places on my breadboard.
Then the problem was that in Spin a program finalizes when there is not more lines, but in ASM the counter of the program (PC) continues the execution to the end ("executing" even data)?
Also:
work?
Clearly it would be an expense to leave the Cog running.
"memory" and "PAR" are memory locations which are used as pointers by the "RDxxx" and "WRxxx" instructions.
You're correct, ":loop jmp #:loop" would also work, but leave the cog running.
Mike