Shop OBEX P1 Docs P2 Docs Learn Events
Shifting data out — Parallax Forums

Shifting data out

g3cwig3cwi Posts: 262
edited 2012-07-02 09:44 in Propeller 1
Hi there

I have a 5x5 dot matrix font encoded into the 25 MSBs of a long. I am trying to shift this out testing the MSB each time. I thought an & would be fine for this.
Pri Letter_shifter | G_data, shift

G_data := $746B5E80

Repeat 5

  Repeat shift from 0 to 4
  
        IF G_data & $80000000 == $8000000    
           BEEP.synth("A", TX_Pin, TX_Freq + shift)      
    
      waitcnt(clkfreq+cnt)
      
    BEEP.synth("A", TX_Pin, 0)
    G_data <<= 1

However, it does not work. I'm guessing that it's something really silly - but being stupid I can't see what it is. Any clues?

Cheers

Richard

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2012-07-01 10:40
    Your second "$8000000" has one too few zeroes. Use the underline to separate groups of digits, and you won't have that problem: $8000_0000. That said, you can just leave off the "== $8000_0000" entirely and let the if check for non-zero.

    -Phil
  • g3cwig3cwi Posts: 262
    edited 2012-07-01 10:45
    Cheers again Phil. I am kicking myself as I felt sure I had made some dumb error with the Spin - never occurred to me that it was something simple!

    Cheers

    Richard
  • JonnyMacJonnyMac Posts: 9,194
    edited 2012-07-01 15:21
    When you get to clocking data to the device you might find something like this useful:
    pub shifter(bits)
    
      bits <<= (32-25)                                              ' shift msb to bit31
      repeat 25
        outa[DTA] := (bits <-= 1) & 1                               ' rotate to bit0 for output
        outa[CLK] := 1                                              ' clock the bit
        outa[CLK] := 0
    
  • Mark_TMark_T Posts: 1,981
    edited 2012-07-01 15:34
    g3cwi wrote: »
    Cheers again Phil. I am kicking myself as I felt sure I had made some dumb error with the Spin - never occurred to me that it was something simple!

    Cheers

    Richard

    Here's a way to stop getting caught out like this again: Only ever have one copy of the constant's value in the CON section - refer to it by name everywhere else (if you get that wrong you'll get a handy error report from the compiler).

    The basic principle of placing values (and strings) in one place only in the source code is very powerful - when someone wants to change the code they won't be able to only change some of the copies of the value (and cause inconsistency), thus another source of errors is eliminated.
  • g3cwig3cwi Posts: 262
    edited 2012-07-02 09:44
    Jon

    Thanks for the tip.

    Cheers

    Richard
Sign In or Register to comment.