Storing Variables in Hub Ram
Jay Kickliter
Posts: 446
I'm running out of room longs in my PASM cog. So I decided to move them to hub memory. It's not working, of course.
Here's the two routines for loading/unloading the variables:
As a test, I ran this code:
which should move the variables from hub data, at hub address par + 10 longs, process the data, and send them back to the hub.
But instead, nothing works at all, leading me to beleive that hub memory is being contaminated.
Can anyone see any issues? I've been trying to figure this out on my own for a few days now, but I just can't get it to work, no matter what I try.
Here's the two routines for loading/unloading the variables:
_load_pitch_vars [b]mov[/b] kt1, #9 [b]mov[/b] kt2, #angle [b]mov[/b] kt3, [b]par[/b] [b]add[/b] kt3, #40 [b]movs[/b] :reader, #kt3 :loop [b]movd[/b] :reader, kt2 [b]nop[/b] :reader [b]rdlong[/b] 0, 0 [b]add[/b] kt2, #1 [b]add[/b] kt3, #4 [b]djnz[/b] kt1, :loop _load_pitch_vars_ret [b]ret[/b] _unload_pitch_vars [b]mov[/b] kt1, #9 [b]mov[/b] kt2, #angle [b]mov[/b] kt3, [b]par[/b] [b]add[/b] kt3, #40 [b]movs[/b] :writer, #kt3 :loop [b]movd[/b] :writer, kt2 [b]nop[/b] :writer [b]wrlong[/b] 0, 0 [b]add[/b] kt2, #1 [b]add[/b] kt3, #4 [b]djnz[/b] kt1, :loop _unload_pitch_vars_ret [b]ret[/b]
As a test, I ran this code:
[b]call[/b] #_load_pitch_vars [b]mov[/b] q_m, uf_pitch_rate [b]call[/b] #_state_update [b]mov[/b] angle_m,uf_pitch [b]call[/b] #_kalman_update [b]call[/b] #_unload_pitch_vars
which should move the variables from hub data, at hub address par + 10 longs, process the data, and send them back to the hub.
But instead, nothing works at all, leading me to beleive that hub memory is being contaminated.
Can anyone see any issues? I've been trying to figure this out on my own for a few days now, but I just can't get it to work, no matter what I try.
Comments
rdlong uses pointers so it should read
rdlong cogramvariable,hubramaddress
hubramaddress is a cog register with the address stored in it
The other routine (for unloading) is identical except that you use a WRLONG instead of a RDLONG.
You said " The other routine (for unloading) is identical except that you use a WRLONG instead of a RDLONG. "
It is posible to only initialize .. :reader position with RD/WR long with CALL to "_load_pitch_vars" and have same routine to both directions.
In my opinion that construct spare LONGS in COG if posible.
:reader
rdlong 0-0,kt2
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nothing is impossible, there are only different degrees of difficulty.
For every stupid question there is at least one intelligent answer.
Don't guess - ask instead.
If you don't ask you won't know.
If your gonna construct something, make it·as simple as·possible yet as versatile as posible.
Sapieha
Jason
Jason, I'm going to try that. First I want to make sure this works. What I really need is 4 entry points, 2 (load, unload) for both pitch and roll variables. Or with a little clean-up, I could probably keep it all in the cog, since I'm just barely running over 495 longs.
Jason
I modified Mike's code to make it a little more compact, does anybody see any glaring collision points when using these two routines?:
Here's a section of the main loop where I call the routines:
And here is the the Kalman filter:
Sorry for the long post, but I just can't figure out where the collision is coming from. Attached for download is the source.