Shop OBEX P1 Docs P2 Docs Learn Events
Can anyone recommend a good SPI object to communicate with a display? — Parallax Forums

Can anyone recommend a good SPI object to communicate with a display?

Don MDon M Posts: 1,653
edited 2011-08-23 16:25 in Propeller 1
I haven't dealt with this interface before but looking to experiment.

Thanks.
Don

Comments

  • jazzedjazzed Posts: 11,803
    edited 2011-08-23 09:13
    Don M wrote: »
    I haven't dealt with this interface before but looking to experiment.

    Thanks.
    Don
    Do you have display in mind already?
  • Bobb FwedBobb Fwed Posts: 1,119
    edited 2011-08-23 09:33
    Attached is the object I use for SPI (shifting) and simple I2C things.
  • Don MDon M Posts: 1,653
    edited 2011-08-23 09:38
    Attached is the display I have in mind. I can talk to it with the 4 (or 8) bit parallel method but was looking at saving some pins if possible. It may turn out harder to do than I imagined.

    What I like about this display is that it will work on 3.3 volts. Makes projects simpler without the need for 5 volts for a display.
  • RaymanRayman Posts: 14,876
    edited 2011-08-23 10:09
    If you look in OBEX, you'll see an SPI object by Beau (Parallax). That's what I started from...
  • John AbshierJohn Abshier Posts: 1,116
    edited 2011-08-23 13:19
    There is a PASM and a Spin SPI engine in the library. Perhaps the Prop Tool should be modified to start with a splash screen that says "Look in the library"

    John Abshier
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2011-08-23 14:07
    Try this little code snippet which does not require an object. Since you are using a character display there is very little information that you need to send it and the timing is not critical, in fact the display needs time after each character to process the information, the maximum time being 600us for everything except the "clear display" command which requires up to 2ms. You can incorporate the test for this command in this function if you like.

    You will not need to read data back from the display as this is only a busy flag and you may as well insert the necessary delay and save an I/O pin.

    BTW, this is untested but should work as the interface is trivial.

    con
      scl   = 0     ' clock
      sdo   = 1     ' data to display sdi
      cs    = 2     ' active low chip select
    
    pub send(char,rs)
      outa[scl]~~                   ' ensure scl is high before we enable cs
      dira[scl]~~
      outa[cs]~                     ' chip select low
      dira[cs]~~
      dira[sdo]~~                   ' make sdo an output to connect to sdi of display
      char ><= 10                   ' reverse last 10 bits so we can send msb first by testing lsb
      char |= rs                    ' add in rs into transmission (rs must be 0 or 1)
      repeat 10
        outa[scl]~                  ' clock low before data setup (also leaves clock high at end)
        outa[sdo] := char&1         ' setup next data bit
        outa[scl]~~                 ' clock the data
        char >>= 1                 ' next bit
      outa[cs]~~                    ' release chip select with clock still high
      ' <<<< insert a waitcnt for around 500us >>>>
      waitcnt(40_000 +cnt)          ' around 500us assuming an 80MHz clock
    
    
  • Don MDon M Posts: 1,653
    edited 2011-08-23 15:59
    @Peter- Thanks for your code. I'll give it a try and let you know how it works.

    @John- Yes I actually decided to look there shortly after I posted this question and found some examples. I never think to look but there are a lot of examples there. The OBEX search is so messed up.
  • RaymanRayman Posts: 14,876
    edited 2011-08-23 16:25
    You're right about the search... I tried looking for the objects I referred to and it took me a while to find them...
Sign In or Register to comment.