Simple spin program puzzler.
lyassa
Posts: 52
I have LEDs connected to pins 20 to 25. I just wanted them to appear like flashing at random so I wrote the simple program below. The program work as expected when the line I labeled as "the line in question" below is commented out as shown in the code. However, if I uncomment the line, the code appears to hang up at that line. The LEDs do not flash anymore. I am sure I have the indentation right.I wonder what the problem could be. Note: for some reason the percent sign is not displaying properly, so I am putting P in place of the percent sign.
CON _clkmode = xtal1 + pll16x _xinfreq = 5_000_000 PUB main | i dira[20..25] := P111111 'outa[20..22] := P111 ' the line in question, works ok when this line is commented out or set to any value between 0 and 6. Does not work when set to 7 or P111 repeat repeat i from 0 to 63 outa[20..25] := i waitcnt(clkfreq/5 + cnt) waitcnt(clkfreq + cnt) outa[20..22] := P111 repeat i from 0 to 8 outa[23..25] := i waitcnt(clkfreq/5 + cnt) waitcnt(clkfreq*3 + cnt)
Comments
Thanks Kuroneko for answering. Something should be wrong then with my circuit. I have it built on a breadboard. It is also a bit more complicated than straight LEDs, but I didn't want to complicate the question with all the details of the circuit. The effect appeared as if it is hanging at that line though. Will check the circuit then will post more details.
Just curious about this line, and others like it:
Did the forum software change your "%" to a "P", or is that the way you entered it?
Thanks,
-Phil
I enetered the P. the Percent sign followed by 6 ones was resulting in four ones and no percent sign. I think it has to do with percent-encoding, http://en.wikipedia.org/wiki/Percent-encoding.
Here I am entering percent followed by 6 ones: %111111, i := %111111
Interesting!!! it is displaying ok now. Last night it didn't???!!! Was it full moon??!! o'well ... may be my spin program will work as well!!!
-Phil