Shop OBEX P1 Docs P2 Docs Learn Events
help with this code, please — Parallax Forums

help with this code, please

nicolad76nicolad76 Posts: 164
edited 2008-04-13 12:59 in Propeller 1
Hi...I made my homework as suggested and I studied a little bit more...so I rewrote the code to drive my EInk display.
I have used Pasd (great!!!) to check the output of the pins...and it is correct (at least to me tongue.gif )...but it still doesn't work. Can anyone take a look and tell me what is wrong?
I cannot wait to see what I am doing that does let the display work....

Display uses a module which receives commands and data.
Commands flow is:
·1) reset device
·2) send command - start load data
·3) send all bytes to make 1 image (60.000 in 1 bit image)
·4) send command - stop load data
·5) show picture.

If bytes are not exactly 60000, than process fails.
Same flow in SPIN code...works!!!!

I can send the spec file of the module if you want...but to emails (on every page it says that I shouldn't publish that file).



Thanks

Comments

  • stevenmess2004stevenmess2004 Posts: 1,102
    edited 2008-04-13 03:41
    I think your problem is with this bit of code
    writebyteDTA
                                    [b]shl[/b]  m_DataByte, #16          '' move data bits to 16..23
                                    [b]or[/b]   [b]OUTA[/b], m_DataByte         '' put data out
                                    [b]nop[/b]
                                    [b]andn[/b] [b]OUTA[/b], m_RW               '' RW low is for writing
                                    [b]or[/b]   [b]OUTA[/b], m_CD               '' CD high is for data
    
                                    [b]mov[/b] tdelay, #2                                                
                                    [b]call[/b] #delay                   
    
                                    [b]andn[/b] [b]OUTA[/b],m_DS                '' DS high to low
    
                                    [b]mov[/b] tdelay, #8                '' ack time is 75 ns 
                                    [b]call[/b] #delay                   '' let's wait 100 ns
                                                                  
                                    [b]or[/b]   [b]OUTA[/b],m_DS                '' DS back to high 
    
                                    [b]mov[/b] tdelay, #3                '' at least 35 ns
                                    [b]call[/b] #delay                   '' before next data
    
    
    


    As far as I can see you never set the data bits in OUTA back to 0. Can you post the spin code that works if this doesn't help?

    Steven
  • kuronekokuroneko Posts: 3,623
    edited 2008-04-13 03:46
    nicolad76 said...
    Hi...I made my homework as suggested and I studied a little bit more...so I rewrote the code to drive my EInk display.
    I have used Pasd (great!!!) to check the output of the pins...and it is correct (at least to me tongue.gif )...but it still doesn't work. Can anyone take a look and tell me what is wrong?

    Probably not related but your ASM code sends the display command last and then keeps sending a display command (ret instruction still points to code after last writebyteCMD call, which is display).

    Now, I don't know how your display copes with that (it may crash or enter an error state ...) Can you try adding a proper call to writebyteCMD and then enter an endless waitcnt loop?
  • nicolad76nicolad76 Posts: 164
    edited 2008-04-13 04:19
    Hi...I have fixed both the issues and it still doesn't work...

    I attached the working version written in SPIN. It is not professionally written but I need it to understand how that display works.

    In the ASM version I have added some reset and init routine..same as SPIN version...

    Do you have any idea what I am doing wrong?

    Thank
  • nicolad76nicolad76 Posts: 164
    edited 2008-04-13 04:20
    Kuroneko....after the display image routine I have put a jump to the end...EInk display do not need refresh..image stays even wiht no refresh and no POWER!!! so I can quit the program....it should work anyway...
  • kuronekokuroneko Posts: 3,623
    edited 2008-04-13 04:41
    nicolad76 said...
    Kuroneko....after the display image routine I have put a jump to the end...EInk display do not need refresh..image stays even wiht no refresh and no POWER!!! so I can quit the program....it should work anyway...

    Well, at the end there is now code, so the cog will attempt to execute data. It's better to put a small loop in there or do the equivalent of cogstop(cogid).

    Anyway, I noticed that you have very small delay counts, e.g. 3 (at least 35ns), then you call code like this

    mov     m_Cnt,cnt
    add     m_Cnt,tdelay
    waitcnt m_Cnt,tdelay
    



    The first instruction loads the current system counter, when waitcnt is executed CNT has advanced at least 4 cycles (add instruction). Meaning your 3 cycle delay will have to wait a full 32bit wrap around (~53sec) before waitcnt returns. I suggest using NOPs or skipping the waitcnt when the delay is below a certain threshold (e.g. everything below 20).
  • nicolad76nicolad76 Posts: 164
    edited 2008-04-13 12:59
    hi...

    You are right...I have noticed that and replaced "delay" with "nop"...I also found another interesting bug..I was sending command byte in the wrong "direction"...starting from LSB instead of MSB...I fixed that too....but still no luck!!!! mad.gif



    I'll keep trying



    Thanks!!!
Sign In or Register to comment.