Shop OBEX P1 Docs P2 Docs Learn Events
Simple spin program puzzler. — Parallax Forums

Simple spin program puzzler.

lyassalyassa Posts: 52
edited 2012-04-20 08:42 in Propeller 1
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

  • kuronekokuroneko Posts: 3,623
    edited 2012-04-13 22:56
    Works for me either way. The only diffference is that the first 3 LEDs flash briefly (uncommented version) before being overridden by outa[20..25] := i.
  • lyassalyassa Posts: 52
    edited 2012-04-13 23:15
    kuroneko wrote: »
    Works for me either way. The only diffference is that the first 3 LEDs flash briefly (uncommented version) before being overridden by outa[20..25] := i.

    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.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2012-04-14 07:11
    lyassa,

    Just curious about this line, and others like it:
    dira[20..25] := P111111

    Did the forum software change your "%" to a "P", or is that the way you entered it?

    Thanks,
    -Phil
  • lyassalyassa Posts: 52
    edited 2012-04-14 08:41
    lyassa,

    Just curious about this line, and others like it:
    dira[20..25] := P111111

    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 Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2012-04-14 09:24
    Okay, thanks. This is an issue I've already brought to Bump's attention. I wish it would get fixed, since it's causing some real trouble in the forum.

    -Phil
  • lyassalyassa Posts: 52
    edited 2012-04-20 08:42
    What I thought is a Spin problem turned out to be a hardware problem. What I was actually doing is switching few LED strips, drawing about 1 amp, via L293. The 100uF capacitor that I had connected to the 12V pin of L293 was bad, and acting as an open circuit. All worked well as soon as I replaced that cap.
Sign In or Register to comment.