Updating Parent Array Values from Child Object?
I've been working on a simple PWM reader in spin for my project and it works great as methods inside a single object file but when I use it as a separate object file I cannot figure out how to update my main code data array from the child object. I understand that I will have to pass the address but I do not know how I can use that address to actually change the value of the data stored in the array. I know that I will have to be careful with the read / write timing here as separate cogs will be using this same memory. Here is the framework for what I've got:
Main Code
Child Object "My PWM Reader 0"
I know it's a simple question but I just cannot find the answer...
Main Code
OBJ
pst : "Parallax Serial Terminal Plus"
PWMR : "My PWM Reader 0"
CON
_CLKMODE=XTAL1+ PLL16X
_XINFREQ = 5_000_000
VAR
long stack[100]
long PWMdata[10]
PUB main
cognew(PWMR.start(0,1,PWMdata),@stack) 'start a new cog with the reader on pin 0, 1 pin only
repeat
'print outputs to terminal
Child Object "My PWM Reader 0"
CON
_CLKMODE=XTAL1+ PLL16X
_XINFREQ = 5_000_000
VAR
long startHi
long stopHi
byte pin0
byte pinNum
byte pin
long PWMdat[10]
long outputArrayAddress
PUB start (startPin, numberOfPins,dataAddress)
pin0:=startPin
pinNum:=numberOfPins
outputArrayAddress:=dataAddress
repeat pin from pin0 to (pin0+pinNum-1)
DIRA[pin]~ 'sets all pins to inputs
repeat
repeat pin from pin0 to (pin0+pinNum-1) 'cycle through and read PWM on each pin
repeat while ina[pin]==1
repeat while ina[pin]==0
starthi:=cnt
repeat while ina[pin]==1
stophi:=cnt
PWMdat[pin]:=stophi-starthi
repeat pin from pin0 to (pin0+pinNum-1) 'cycle through and update PWM data array values
outputArrayAddress[pin]:=PWMdat[pin] 'need help with this
I know it's a simple question but I just cannot find the answer...

Comments
long[childdata] := 1
The main method can then read the data at any time.
Or, as an example in the child obj do long[outputArrayAddress] := 1
then in the main method read the data in PWMdata.
You can't cognew a child object's method. Put the cognew in a new method in the child object.
You need to do long[baseptr][offset] to index arrays by pointer.
main.spin:
childobject.spin:
VAR long stack[64] word arrayptr PUB init(_arrayptr, a, b) arrayptr := _arrayptr cognew(loop(a, b), @stack) PRI loop(a, b, c) | i repeat repeat i from a to b long[arrayptr][i] := read_val(i)Also, _clkmode and _xinfreq in child objects are ignored.
I got it figured out. It was mostly the cognew() placement causing something I had already tried to fail.