Shop OBEX P1 Docs P2 Docs Learn Events
EA DOGM128-6 Display with SPI — Parallax Forums

EA DOGM128-6 Display with SPI

ClemensClemens Posts: 236
edited 2012-04-23 03:51 in Propeller 1
Hi all,

this will be a loooong question, so if you're in a hurry I advise you to ignore this posting.
Thanks to all those who take the time to read it.
I'm stuck with my EA DOGM128-6 Display.
http://www.electronic-assembly.de/eng/dog/dog.htm
I bought it because I like the friendly Triceratops in the adds.

dogm2.jpg

I'm stuck mainly because I don't know if I got the hardware setup right so I don't know if I can even expect to get something on the screen when trying out some code.
I interpreted the datasheet (http://www.electronic-assembly.de/eng/pdf/grafik/dogm128e.pdf) that I have to make the following connections:
  • SI and CLK to two propeller pins.
  • CS to ground (it says Chip select: active low) Is that correct?
  • A0 also to ground for command input, which i thought would be enough for testing by initializing the display and setting all pixels to black:
dogm3.jpg

dogm.jpg

Now I must admit that I'm stuck with SPI just the same.
I read a couple of articles (http://en.wikipedia.org/wiki/Spi) but it sais that SPI is two way communication, but the display doesn't have an output.
I also found an SPI Object on the german forum and it is even for another Dogm Display http://propellerforum.sps-welt.de/viewtopic.php?t=26, but I couldn't get it to work when I tried things like·putting these commands in the init section:


  Write_cmd($40)            
  Write_cmd($A1)        
  Write_cmd($C0)                               
  Write_cmd($A7)                                                                                        
  Write_cmd($A2)                                                        
  Write_cmd($2F)                          
  Write_cmd($F8)           
  Write_cmd($00)                        
  Write_cmd($27)               
  Write_cmd($81)                   
  Write_cmd($16)                  
  Write_cmd($AC)                      
  Write_cmd($00)                 
  Write_cmd($AF)            
  Write_cmd(%10100101)    



I also looked at the SPI example "Assembly Code Examples for the Beginner: SPI Engine Demo"
http://forums.parallax.com/showthread.php?p=601870
but it is also two way communication, right?

So you see I'm totally lost. This may be a too big step for me right now, I now. But if you have any suggestions other than "put that thing in the drawer and don't take it out until someone has written an object for it" I would really appreciate it...
Thanks for reading,·smile.gif

Clemens
·
«13

Comments

  • mirrormirror Posts: 322
    edited 2008-01-19 00:37
    Chip select is Important!!!

    It needs to be driven in accordance with the data sheet - it tells the device where the start of the command is.

    So the sequence is: (for every command)
    - Chip select ON
    - Send 1 command - not 1 byte, but 1 whole command sequence.
    - Chip select OFF

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • deSilvadeSilva Posts: 2,967
    edited 2008-01-19 01:08
    Clemens, I have a similar display on my desk for some days now.... but shifted it's connection to the weekend, still hoping I have so many caps smile.gif

    I am sure we will get it working tomorrow... you will know what time it is now around Greenwich smile.gif

    Post Edited (deSilva) : 1/19/2008 1:13:59 AM GMT
  • ClemensClemens Posts: 236
    edited 2008-01-19 01:28
    Thanks Mirror, i thought it could be just·pulled·to ground because that's how it looks like in the SPI object from UWE on the german forum:
    http://propellerforum.sps-welt.de/viewtopic.php?t=26
    I just had a look at the ST7565R datasheet (http://www.lcd-module.de/eng/pdf/zubehoer/st7565r.pdf) on page 64 and I'll try to understand this. I'm a little confused that the timing is so flexable.

    Thanks deSilva I was hoping you have one since it was your posting from a couple of weeks ago where I first saw the dogm.
    So now there's hope that I'll get this thing running. good.

    smile.gif

    Clemens
  • deSilvadeSilva Posts: 2,967
    edited 2008-01-19 02:00
    UWE's code is no good for this display. It is much simpler..
    But good night now ..
  • OzStampOzStamp Posts: 377
    edited 2008-01-19 10:41
    Hi Clemens.

    How much do these display's cost ? With the SPI interface.

    The interface chip these units use is a sistronics 7036 I think..
    It has a 4 wire SPI protocol..

    Cheers Ron Mel OZ
  • deSilvadeSilva Posts: 2,967
    edited 2008-01-19 10:54
    They use the Sitronix ST7565R.
    Despite their high WAF, they are extremely low cost,
    128x64 around 22 Euro
    132x32 around 14 Euro
  • ClemensClemens Posts: 236
    edited 2008-01-19 11:06
    Plus another 5 to 10 Euros (depending on the color) for the backlight. There is also a touchpanel for it.
    Yes, I'm starting to understand why it said 4-wire SPI and not just SPI. wink.gif
  • deSilvadeSilva Posts: 2,967
    edited 2008-01-19 22:22
    Sorry Clemens,
    I should have posted something long ago... But it turned out to be a little bit tricky... The commands are NOT well documented...

    Edit:
    improved version in next posting.. smile.gif

    Post Edited (deSilva) : 1/20/2008 12:16:50 AM GMT
  • ClemensClemens Posts: 236
    edited 2008-01-19 23:27
    Thank you so much, DeSilva!
    Just tried it but couldn't get it to work so far...
    shakehead.gif
    I think I have the four wires connected correctly, but no luck so for.
    But thanks anyway at least now I know that it must be something wrong with my setup...

    Clemens
  • ClemensClemens Posts: 236
    edited 2008-01-19 23:37
    Stupid question: Do I have to connect the reset pin of the display?
  • deSilvadeSilva Posts: 2,967
    edited 2008-01-20 00:03
    Clemens:
    Do you have any reactions at all? Looking at your photograph the caps look fine... You have to connect CS of course.
    RESET was WRONG at GND!
    It is NON-RESET smile.gif
  • ClemensClemens Posts: 236
    edited 2008-01-20 00:15
    No, no reactions at all.

    Yes, I connected:
    SI (36) to pin 0
    CLK (37) to pin 1
    Reset (38) nowhere
    A0 (39) to pin 2
    CS (40) to pin 3

    I'm confused that there are no "waitcnt"'s in the program.
    does this mean it works at the highest possible spin-speed?
    Do I have t set :
    _CLKMODE = XTAL1 + PLL16X
    _XINFREQ = 5_000_000
    ?
  • deSilvadeSilva Posts: 2,967
    edited 2008-01-20 00:19
    Clemens RESET is 39 and A0 is 38 !!!
    It works with all speeds! I tested without crystal, and with 80 MHz,,,
  • ClemensClemens Posts: 236
    edited 2008-01-20 00:21
    oh, sorry, I connected it right though, it was just a typo in the post.
  • deSilvadeSilva Posts: 2,967
    edited 2008-01-20 00:38
    :-(
    So, again:

    36 -> I/O 0 (= pin 1)
    37 -> I/O 1
    38 -> I/O 2
    39 -> plus 3V
    40 -> I/O 3 (=pin 4)

    Should work! Well, MUST work!! Just run the program...
  • ClemensClemens Posts: 236
    edited 2008-01-20 01:01
    yes that's how it is connected, and yet it doesn't work :-(
    I didn't have reset connected to plus 3V but did so now - still nothing happens when I load the program.
    I'm sorry to take up your time like this.
  • ClemensClemens Posts: 236
    edited 2008-01-20 01:18
    Waahhhnsinn! Danke, spitze!

    Oh, sorry, my german breaks through when I'm getting emotional... wink.gif
    I just changed the Initialization to the defaults in the datasheet:


    BYTE $A1 'ADC reverse
    BYTE $C0 'reverse COM
    BYTE $A6 'normal display
    BYTE $A2 'set bias 1/9
    BYTE $2F 'set Booster
    BYTE $F8, $00 'set Booster x4
    BYTE $27 ' change here for contrast: $24..$27
    BYTE $81, $16 'set contrast ($3f to $00)
    BYTE $AC, $00 'no static indicator
    BYTE $AF ' Display ON

    and now it's working!
    Thanks DeSilva, I'm in deep debt, I would have never gotten there myself...
    ... and the funny thing is, I almost understand every part of your program.
    this will keep me occupied for a while.
    Cool.

    Clemens
  • deSilvadeSilva Posts: 2,967
    edited 2008-01-20 01:19
    It is extremely useful time - I had to connect this display anyhow - But I cannot understand why it doesn't work with you..

    I made some changes in the contrast setting... Maybe you will change them back to the recommended values...
    But that cannot be the reason... If the contrast is bad, the display should look "black" - that's how it started with me 4 hours ago smile.gif
  • ClemensClemens Posts: 236
    edited 2008-01-20 01:21
    haha, yeah yeah yeah.
  • deSilvadeSilva Posts: 2,967
    edited 2008-01-20 01:24
    Great! I suspect the contrast values $24..$27 have to do with the capacitance... As I had not 0 1µF I used 4.7 µF... This is within the limits, but it turned the display black.. So I had to adjust for it...

    I will post a minor update of the test program in 10 minutes, so you can see some more of the commands in action...
  • ClemensClemens Posts: 236
    edited 2008-01-20 01:27
    yes it is the contrast. there is nothing visible with a setting of three. maybe its the background lighting. In the datasheet it sais that the contrast needs to be set individually so probably it varies form display to display. Who cares - its working, haha.
  • ClemensClemens Posts: 236
    edited 2008-01-20 01:27
    our postings do overlap again...
  • deSilvadeSilva Posts: 2,967
    edited 2008-01-20 02:09
    Last Update for tonight:
    '' MPE_SPI_DOGM_005
    '' DOGM 4-PIN 2008-01 by deSilva
    
    ' ----- The following routine is a test routine
    pub checkOut | line , scroll
      init
    
      ' slow wipeout
      REPEAT line FROM 0 TO 7 
         clearLine(line)
    
      
      spiWrite(string($B0,$10),3,0)
      REPEAT 16
         spiWrite(string($01,$03,$07,$0f,$1f,$3f,$7f,$ff),8,1)
    
    
      spiWrite(string($B1, $10),3,0)
      REPEAT 16
         spiWrite(string($18,$3c,$7e,$ff,$10,$08,$10,$08),8,1)
    
      spiWrite(string($B2,$10),3,0)
      REPEAT 16
         spiWrite(string($01,$03,$07,$0f,$1f,$3f,$7f,$ff),8,1)
    
      spiWrite(string($B6, $10),3,0)
      REPEAT 16*8
         spiWrite(string($FF),1,1)
    
     aString(string("Regards:",10,"deSilva!"))
     
    
      REPEAT 32*5
        scroll++
        scroll &= 63
        scroll |= $40
        spiWrite(@scroll,1,0)
        waitcnt(CNT+clkfreq/20)
    
    
      REPEAT
        spiWrite(string($A6),1,0)
        waitcnt(CNT+clkfreq)      
        spiWrite(string($A7),1,0)
        waitcnt(CNT+clkfreq)
        
    PUB aString(s) | n, g, p
      n:= -16
      p := 0
      REPEAT WHILE g := BYTE[noparse][[/noparse]s++]
         IF g == 10
            p := 4   ' next line
            n :=-16
         ELSE
            aGlyph(g, n+=16, p)
    
    
    '----- Here starts the driver
    
    CON 
      #0,SD,SCL,A0,CS   ' using I/O 0..3 change whenever appropriate
    PUB spiWrite(dataAddr, nmbBytes, thisA0): data
    
      outa[noparse][[/noparse]CS]~
      outa[noparse][[/noparse]A0] := thisA0
      REPEAT WHILE nmbBytes-- > 0
        IF dataAddr
          data := BYTE[noparse][[/noparse]dataAddr++] >< 8 'revert each byte         
        REPEAT 8                   'transfer from D7 to D0
          outa[noparse][[/noparse]SCL]~               'clock goes low
          outa[noparse][[/noparse]SD] := data
          outa[noparse][[/noparse]SCL]~~              'transfer at rising edge
          data >>= 1
      outa[noparse][[/noparse]a0]~                                             
      outa[noparse][[/noparse]CS]~~      
    
    
    
    DAT
    initDOGM BYTE $40   'Start line =0
          BYTE $A0      'ADC reverse
          BYTE $C8      'reverse COM
          BYTE $A6      'normal display
          BYTE $A2      'set bias 1/9
          BYTE $2F      'set Booster
          BYTE $F8, $00 'set Booster x4
          BYTE $25      ' change here for contrast: $24..$27
          BYTE $81, $03 'set contrast ($3f to $00)
          BYTE $AC, $01 'no static indicator
          BYTE $AF      ' Display ON      
    initDOGMend BYTE
    
    clearDOGM BYTE $B0   ' set line
          BYTE $40
          BYTE $10        ' set low nibble
          BYTE $00        ' set high nibble
    clearDOGMend BYTE
    
    PUB init
      OUTA[noparse][[/noparse]CS]~~
      OUTA[noparse][[/noparse]SCL]~~
      DIRA[noparse][[/noparse]SD..CS]~~
      ' SpiWrite(string($E2),1,0) ' internal reset
      SpiWrite(@initDOGM, constant(@initDOGMend-@initDOGM) , 0)
    
    PUB clearLine(line)
      clearDOGM &= $f0
      clearDOGM |= line
      spiWrite(@clearDOGM, constant(@clearDOGMend-@clearDOGM) , 0)
      spiWrite(0, $80, 1) 
    
    
             
    PUB aGlyph(glyph, dPos, startPage)   | posString, shift, shift0, c, cBase  , page, row
     cbase := $8000+ glyph/2*128
     shift0 := glyph//2
     posString.byte[noparse][[/noparse] 2] := $00 + dPos&15
     posString.byte[noparse][[/noparse] 1] := $10 +(dPos>>4)
     REPEAT page FROM 0 to 3
        posString.byte[noparse][[/noparse] 0] := $B0 + page+startPage
        spiWrite(@posString,3,0)
        REPEAT shift FROM shift0 TO 31+shift0 step 2
          c :=0 
          REPEAT row FROM 0 to 7
            c |= ((LONG[noparse][[/noparse]cBase][noparse][[/noparse]row+page*8]>>shift)&1) << row
          spiWrite(@c,1,1)
    

    Post Edited (deSilva) : 1/20/2008 2:33:01 PM GMT
  • ClemensClemens Posts: 236
    edited 2008-01-20 02:18
    nice scrolling, but the glyphs are scrambled. will post a picture tomorrow..
  • deSilvadeSilva Posts: 2,967
    edited 2008-01-20 13:02
    I post this simple application as it also shows how to use COGs...

    The driver (version 5) is in the enclosed ZIP. Sorry I changed some conventions:
    spiWrite is now called write
    init has a parameter ("upside down", FALSE or else)
    clearLine is now called clearPage

    I have a low cost 32 lines display only. however it contains full 64 lines RAM and can be scrolled !

    '' MPE_SPI_GOLEM_001 (modified twice)
    '' A GameOfLife for the DOGM 4-PIN 2008-01 by deSilva
    
    '  A most simple implementation, the status is kept in bytes
    '  in a "lines" x 128 array ("lines" are 32 or 64 resp.)
    '  It can be experimented with "divide and conquer"; computing
    '  the next generation is split to another, or 2 or even 4 COGs
    
    '  It shows that the SPIN implementation of SPI is NOT a bottleneck
    '  for this kind of algorithms 
    
      _clkmode     = xtal1 + pll8x             ' change here!
      _xinfreq      = 10_000_000               ' change here!
    
      LINES = 32     ' change to 64 for full display
      PARTS =  4     ' number of additional COGs working in parallel (1, 2 or 4)
                     ' -1 (rather than epected "0") indicates NO parallelism
      ledPin = 6      ' idle indicator
    
    OBJ
      gdogm : "MPE_SPI_DOGM_005"
    
    VAR
      BYTE complete[noparse][[/noparse]||PARTS]       ' feed back of COGs when completed
      BYTE GOL[noparse][[/noparse]128*lines]          ' new generation is assembled here
      BYTE upperBorder[noparse][[/noparse]128]        ' border, just zeros
      BYTE GOLB[noparse][[/noparse]128*lines]         ' old generation to read and to display from
      BYTE lowerBorder[noparse][[/noparse]128]
    
    PUB golem | x, i, completed, part, aStack[noparse][[/noparse]20*||PARTS]
    
      DIRA[noparse][[/noparse]ledPin]~~                       ' will indicate main COG idle
    
      gdogm.init(0)
    
      X:=CNT
      REPEAT i FROM 0 to constant(128*LINES-1)
         GOL[noparse][[/noparse] i] := (?X)&1
    
        
      REPEAT
          
          LONGMOVE(@GOLB, @GOL, constant(128/4*LINES))  
    
          IF PARTS<1  ' no parallel COGS!
             nextGeneration(0, @complete)
          ELSE
             REPEAT part from 0 to PARTS-1 ' recruit some COGs for the dirty work
               cognew(                                                         {
    }              nextGeneration(part*constant(128/||PARTS), @complete+part), {
    }              @aStack+20*4*part)
    
          displayGOL                       ' displays old GOLB!
          
          outa[noparse][[/noparse]ledPin]~~
    
          REPEAT                            ' wait for all COGs ready
              completed~
              REPEAT part FROM 0 to ||PARTS-1
                 completed += complete[noparse][[/noparse]part]
          UNTIL completed == ||PARTS    
          outa[noparse][[/noparse]ledPin]~
    
    PRI nextGeneration(offset, completePointer) |i,c
          longfill(@GOL+offset*lines,0, constant(128/4/||PARTS)*lines) 
          BYTE[noparse][[/noparse]completePointer]~
          REPEAT i FROM offset*lines to (offset+constant(128/||PARTS))*lines-1
            c := GOLB[noparse][[/noparse]i-1]+GOLB[noparse][[/noparse]i+1]+GOLB[noparse][[/noparse]i-lines]+GOLB[noparse][[/noparse]i+lines]+GOLB[noparse][[/noparse]i+1+lines]+    {
    }             GOLB[noparse][[/noparse]i-1+lines]+GOLB[noparse][[/noparse]i+1-lines]+GOLB[noparse][[/noparse]i-1-lines]
            IF c == 3 or (C==2 and GOLB[noparse][[/noparse] i])
               GOL[noparse][[/noparse] i] := 1
          BYTE[noparse][[/noparse]completePointer]:=1     
    
    
    PRI displayGOL |page, posString,col, c, cc[noparse][[/noparse]128/4],refAddr
    
      posString.byte[noparse][[/noparse] 2] := $00 '+ dPos&15
      posString.byte[noparse][[/noparse] 1] := $10 '+(dPos>>4)
      REPEAT page FROM 0 TO constant(lines/8)-1
    
         posString.byte[noparse][[/noparse] 0] := $B0 + page
         gdogm.write(@posString,3,0)
         REPEAT col FROM 0 to 127
            c :=0
            refAddr := col*lines+page*8
              REPEAT 8          
                c := (c<<1) + GOLB[noparse][[/noparse]refAddr++]
            BYTE[noparse][[/noparse]@cc+col] := c><8
         gdogm.write(@cc,128,1)
    '=== The End
    



    Edit:
    Sory I had to modify this again for a grave - but not noticeable - error in the COG completion logic ...

    Post Edited (deSilva) : 1/20/2008 3:02:36 PM GMT
  • ClemensClemens Posts: 236
    edited 2008-01-20 13:12
    here is the image:

    dogm4.jpg

    I see that the scrambling is because you have the 132x32, right? (*overlapped post again*)

    But don't tell me what to change, this is a good exercise for me!
    I'll report back as soon as I figured it out.
    Cool, it also shows how to use the internal font!

    This must go to the wiki or Object Exchange as soon as it is finished.
    Thank you,

    Clemens
  • deSilvadeSilva Posts: 2,967
    edited 2008-01-20 14:17
    Interesting: It shows that yours display also has 132 columns, 4 of them not advertised smile.gif I had changed the clearPage routine for this already ($84 rather $80)

    The scrambling is unclear....
    Can you try the GOLEM please smile.gif
  • deSilvadeSilva Posts: 2,967
    edited 2008-01-20 14:33
    Clemens,
    I think it was my fault: When you have just copied the code from the browser window - WITHOUT FIRST getting the true contents with "respond to message" - some brackets might have got lost! [noparse][[/noparse] 0], [noparse][[/noparse] 1] , [noparse][[/noparse] 2] smile.gif

    Best use the driver 005 in the zip!
  • ClemensClemens Posts: 236
    edited 2008-01-20 15:00
    Everything is fine now. No scrambled text in your MPE_SPI_DOGM_005 anymore.
    Life is forming on my display. Beautiful!
    smile.gif

    I will try to get·a smaller font running·(starting with a bitmap font like the hydra-people do for their games.)
    Unfortunately I still have some work to do, or there will be some very unhappy customers tomorrow. LOL
    Thank you so much again, this was a giant step for me, I've learned a lot this weekend.

    Clemens
  • ClemensClemens Posts: 236
    edited 2008-01-27 00:27
    Hi,

    Here is my small Dogmfont. It is non-mono-space, so characters have different widths between one and five pixels. This way if you're lucky you can get 30 Characters per line.
    It requires deSilvas driver "MPE_SPI_DOGM_005.spin" (5 posts up).

    I tried my best to program this like the pros do - but any criticism is very welcome. smile.gif
    Next I will try to get one bit images from an SD-Card to the screen. Guess I'll take a look at Rayman's website to see how to do that...

    Cheers,


    Clemens

    dogm5.jpg
Sign In or Register to comment.