Shop OBEX P1 Docs P2 Docs Learn Events
logic error, please help — Parallax Forums

logic error, please help

yarisboyyarisboy Posts: 245
edited 2010-10-05 12:49 in Propeller 1
I'm debugging the attached program. The scope shows my clock pin and enable pins are working correctly. The scope also shows that I'm not getting a bit-stream out of my data-out pin. The enable pin stays low for a time proportional to the number of bits I'm shifting out. The receiving chip is designed to latch-in the sent data bit on a low to high transition of the clock pin. The clock is currently set at 10 Hz.

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2010-10-05 11:36
    It may not make any difference, but I don't understand why you start up another cog just to run the frequency synthesis object.

    If you look at the code for SYNTH, you'll see that it just sets up one of the counters to run on its own, then returns to the caller. You could just as easily put the call to Freq.Synth in place of the COGNEW in your main method.

    LBIT shifts its parameter So, but that's a parameter that gets thrown away when LBIT returns. Sob in SHIFTOUT never gets changed.

    You could make LBIT work like this:
    PUB LBIT(So)                         'for each call, one bit is loaded on the data pin for shift out.
      DIRA[Dpin]~~
      OUTA[Dpin] := So >> (Bits-1)      'Dpin IS THE DATA PIN, So IS THE BIT STRING TO SEND, B IS THE NUMBER OF BITS TO SEND.
      return So << 1                 
    
    and in SHIFTOUT, you'd have

    Sob := LBIT(Sob) 'Load One Bit per loop. We don't care (yet) if clk pin is low or high.

    You could also just build LBIT into SHIFTOUT rather than moving it into a separate method. It's only called once in SHIFTOUT and it's short.
  • yarisboyyarisboy Posts: 245
    edited 2010-10-05 12:49
    When I launched a cog it was because I misunderstood the demo program for Synth.spin. The attached code works the way I interpret it should from the receiving chip data sheet. I'm going to replace the receiving chip on the chance that what ever knocked out my prop last week also zapped the receiver chip. As frame of reference, a week ago I didn't even know what waitpeq was. This code represents 10% of a bottom-up application development effort so I'll be back from time to time.
    Thanks a bunch,
    Stan
    P.S. Hardware was good. Had to massage the numbers and edit the code. I've got it displaying 4 digits on an LED display. With the long wires on my breadboard it can handle a clock rate of just over 8000 Hz. (fast enough for my needs)
Sign In or Register to comment.