Problems moving an array to a new cog
Joms
Posts: 279
I am trying to move an array address to a new cog. My code works without starting a new cog, so I know it has to do with trying to move the address of the array. The array I am dealing with is 50 longs.
If I change the addr in the if statement to the variable name, it works ok, so I know it has to do with passing the address. Is there a different way I should pass the address? Eventually I will move this part to its own object.
I left out a the complicated part of the code because it isn't commented yet, and just complicates it...
Thanks in advance!
Var long stack[500] long LEDstrip1 PUB Main | i, r cognew (sendLED(@Ledstrip1), @Stack) PUB sendLED(addr) | i, t repeat i from 5 to 9 If (addr[t] & |< i) outa[PinLEDdata]~~ else outa[PinLEDdata]~ more code goes here...
If I change the addr in the if statement to the variable name, it works ok, so I know it has to do with passing the address. Is there a different way I should pass the address? Eventually I will move this part to its own object.
I left out a the complicated part of the code because it isn't commented yet, and just complicates it...
Thanks in advance!
Comments
Also, you mention 50 longs, where are they? If addr is the address of a long array then long[addr][idx] should be used (idx = 0..49).
I did try that earlier and it didn't work. I did try again with a few different things, and still couldn't figure the syntax of it out.
-Mike G
Forgive me here, but what do you mean by unsigned?
I attached the file I am working with...it isnt commented out, but should be pretty easy to see the idea of what I am doing.
Basically, I have a strip of 50 LEDs that use the LPD6803 IC. I am trying to build something that will allow me to chase them, and change colors, etc. Basically, every long in the variable controls one LED. 5-bits are red, 5-bits green, 5-bits blue. I am hoping when I am done I can be able to shift bits left, right, etc to chase, or just set the array to all one number to make a steady color.
If I am over complicating this and there is a much simplier way, please point it out. I am fairly new to data and playing with this LED strip to try and learn more about managing data like the sparkfun LED strip...
kuroneko - I did get yours to work... And read up on what I was doing wrong...
Mike - I tried yours just because I wanted to learn more about how you did it... And found a new problem. I can't get my waitcnt to work, even in the simplest form.
when I use the 1/2 second, I get no delay, when I use the 1 second, it doesn't go on. I checked and the crystal is ok... Wondering if it is a problem with the cog?
On a side note, I am still haveing problems actually making a new object and getting the memory address to move to the object.
Now I just need to figure out the waitcnt problem... I have been looking at the book and appears to be the right syntax, however it locks the prop up when I use the command...
THANKS FOR THE HELP!