ADC Parameter clarification Please!
TurboMan
Posts: 19
In Beau's ADC driver code there are two parameters called sample. By the Prop Manual docs PUB (parameter) is "parameter is essentially a long variable and can be treated as such" and the COGNEW (ABC, parameter) "is passed into the COG's PAR register" and it is stated that they can both be local parameters.
I also see in Beau's documentation the wrlong par command says it writes the sample back to spin var "sample". For my own clarification does the "wrlong...., par" instruction send the data to the PUB (sample) and then the Cognew sample would be the data from the PUB (sample)? In other words the PUB.... (sample) is the actual variable? Correct? If true then what if I had multiple PUB (parm1,parm2,parm3). Would I then change the wrlong ,par to wrlong ,parm1 ?
PUB SigmaDelta (sample)
cognew(@asm_entry, sample) 'launch assembly program in a COG
...
DAT
....
wrlong asm_sample,par 'write sample back to Spin variable "sample"
I also see in Beau's documentation the wrlong par command says it writes the sample back to spin var "sample". For my own clarification does the "wrlong...., par" instruction send the data to the PUB (sample) and then the Cognew sample would be the data from the PUB (sample)? In other words the PUB.... (sample) is the actual variable? Correct? If true then what if I had multiple PUB (parm1,parm2,parm3). Would I then change the wrlong ,par to wrlong ,parm1 ?
PUB SigmaDelta (sample)
cognew(@asm_entry, sample) 'launch assembly program in a COG
...
DAT
....
wrlong asm_sample,par 'write sample back to Spin variable "sample"
Comments
I assume that you are talking about the ADC.spin located in the Propeller Tool examples directory.
The 'parameter' passed in both the PUB and from the cognew command are one in the same and represent the address of the variable you want to write the result to.
The COG's PAR register holds the address of the variable we want to write to since we are not using an @ directly in 'sample'.
If you had multiple PUB (parm1,parm2,parm3) , you could do that, but you would have to call the cognew using the @ symbol with parm1 like this...
cognew(@asm_entry, @parm1)
... that way within PAsm you could write to parm1, parm2, and parm3 like this...
likewise if you allocated your variables that you wanted to write to somewhere outside of the SigmaDelta PUB (The way it was intended), then your code might look something like this...
...in this case parm1, parm2, and parm3 would still be accessed from PAsm in the same way mentioned above ... because we are defining the value of 'sample' within the ADC.spin object as the address of 'parm1'