Can't use "PAR" to write to main ram...why?
3dogpottery
Posts: 78
I know you can't. I tried it, and indeed, it doesn't work. The reason for this is given in the Propeller Manual on page 170: "the PAR register is read only, and should only be accessed as a source (s-field) register value". Ok, fine. But why doesn't the instruction wrlong, ValReg, PAR work? PAR is the source register. The Propeller Manual says that the address in main memory to which the value will be written to is stored in the "sorce" field of the instruction. So, what am I missing here?
Comments
One is the "real" one, the other one is just like any other cog ram location.
The read-only one can only be accessed on the "source" location of a pasm command: xxx ddd,sss
If you write to it you are writing to ram, and the word PAR is just a reserved word that now will be a generic ram location instead.
Writing to Hub ram with the d-field as source does not count as read-only, as the rule is d or s side.
So your above example should work.
If you've tried to use PAR this way and it doesn't seem to have worked, try posting your code here so we can point out what's wrong with your attempt. Remember:
EDIT: Mike beat me to it -- as usual.
The answer is
wrlong, variable, PAR does not work. He is right
wrlong variable, PAR does.
Lesson for beginners, not only is the indenting critical in SPIN
but so is the syntax in both SPIN and PASM.
It is extremely important for beginners to lay out the PASM code neatly
so that such mistakes will stick out more readily.
And no one asked "How do you know the command did not work?"
The mistake could well have been in how the data was being read.
I have learned that beginners must learn to be very careful.
(And to catch little bitty commas takes eagle eyes!)
H
Do tell us exactly how it went, with code.
H
I needed to copy PAR into another variable since I am working with an array of longs passed to the assembly routine. So, I don't know what I was initially doing wrong; It may have been the extra comma delimiter. Incidentally, I am trying to write an SPI assembly routine to read a register the UM6-LT UMI from CH Robotics. I am getting nowhere fast. However, I am a very stubborn individual, and will not give up!
Thanks for all the suggestions. I have found this forum very helpful, and one of these days I would like to contribute. As for now, I don't want to abuse this privilege by appealing to the forum every single instance I get into trouble. When I have to fight for the answer, I never forget the solution!