Shop OBEX P1 Docs P2 Docs Learn Events
Every first bit lost by shift out a byte to a LCD with SPI-Interface ?? — Parallax Forums

Every first bit lost by shift out a byte to a LCD with SPI-Interface ??

tdustdus Posts: 6
edited 2006-12-05 19:49 in Propeller 1
Hi,

I am a Propeller fan from germany.

My question is:
By shift out a byte to the lcd every first bit is lost?
when I shift left before I send it works, but i dont understand this.


PRI SPI_Write(lcddata)        ''serial send to lcd

  lcddata <<=1                  '<-----  why I must do this ??? without this every first bit is lost
  
  repeat 8                                     'send 8 bits to the lc-display
    waitcnt(cnt += spi_timing)                 '100us wait
    outa[noparse][[/noparse]SDC] := 1                             'clock goes high
    outa[noparse][[/noparse]SDO] := (lcddata >>= 1) & 1           'Shift the bit to the SDO Pin
    waitcnt(cnt += spi_timing)                 '100us wait
    outa[noparse][[/noparse]SDC] := 0                             'clock goes low and write the bit 





The complete code (if you need) is on my Propellerpage on www.tdus.de


Thanks
Uwe

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2006-12-05 18:23
    You have to shift lcddata left initially because the "(lcddata >>= 1) & 1" shifts the data to the right before it uses the low order bit. What you are doing is fine. If you want to avoid the initial shift, you must separate the use of the bit and the shift as follows:
    repeat 8
      waitcnt(clkfreq / 10000 + cnt)   'Wait for 100us
      outa[noparse][[/noparse]SDC]~~    ' clock goes high
      outa[noparse][[/noparse]SDO] := lcddata
      lcddata >>= 1
      waitcnt(clkfreq / 10000 + cnt) 'Wait for 100us
      outa[noparse][[/noparse]SDC]~  'clock goes low
    
    
  • tdustdus Posts: 6
    edited 2006-12-05 19:49
    o.k. is clear as daylight.

    Thank you very much tongue.gif
Sign In or Register to comment.