Shop OBEX P1 Docs P2 Docs Learn Events
how to work with timing? — Parallax Forums

how to work with timing?

nicolad76nicolad76 Posts: 164
edited 2008-05-18 13:00 in Propeller 1
Hi guys,
I have this display interface connected to my Prop. I wrote the driver that implements all functions and everything works but the most important feature. One of the functions is to work only on part of the display so I do not need to refresh the entire picture.

The problem seems to be a timing issue. If I debug the function with PASD then it works. If I run it at 80Mhz then it doesn't...wierd snce all other functions work!!!!.

Now...attached you can see the time chart and the times for the different operation. I tried to insert delays almost everywhere and covering almost all possible combinations...no way...now I need a scientific way to fix this problem [noparse]:)[/noparse]

The ACK signal goes up and down then I thought to intercept the falling edge by using waitpeq and waitpne...but I failed again.

Can you guys help to understand how to work with "synch" between prop and my display?

Thanks!!!
628 x 294 - 21K
651 x 237 - 42K

Comments

  • Ken PetersonKen Peterson Posts: 806
    edited 2008-05-15 12:30
    What display are you using?· I don't see enough information here to understand what you are trying to do.· Can you post a data sheet?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • nicolad76nicolad76 Posts: 164
    edited 2008-05-15 22:17
    yhea...sorry...I shoul dbe more clear.
    My question is about what should I do to "wait" the right moment to set H_DS high.

    This is what I do.

    or OUTA, m_DataByte ' set data bits

    andn OUTA, m_RW ' set R/W direction
    andn OUTA, m_CD ' set Command/Data selector

    mov timer, cnt ' I wait a set up time
    add timer, #T_Setup
    waitcnt timer, #T_setup

    andn OUTA,m_DS ' set m_DS (=H_DS) low

    ' HOW DO I WAIT FOR H_ACK?

    or OUTA,m_DS ' set m_DS (=H_DS) high



    I see that H_ACK is undefined right after DS goes low, then it goes HIGH then LOW then undefined.
    It is not clear to me how I should wait before setting H_DS low.

    Thanks
  • Mike GreenMike Green Posts: 23,101
    edited 2008-05-15 22:22
    Read the descriptions of the WAITPNE and WAITPEQ instructions. These will cause the cog to "stall" until a particular I/O pin or group of pins has a particular state (or stops having it).
  • nicolad76nicolad76 Posts: 164
    edited 2008-05-15 22:28
    I did it but probably I am still doing something wrong.
    The code should look like

    or OUTA, m_DataByte ' set data bits

    andn OUTA, m_RW ' set R/W direction
    andn OUTA, m_CD ' set Command/Data selector

    mov timer, cnt ' I wait a set up time
    add timer, #T_Setup
    waitcnt timer, #T_setup

    andn OUTA,m_DS ' set m_DS (=H_DS) low

    waitpeq 1,m_ACK ' detect falling edge of m_ACK
    waitpeq 0,m_ACK

    or OUTA,m_DS ' set m_DS (=H_DS) high


    but cog hangs forever....
    Is the undefined part of ACK involved here?
  • Mike GreenMike Green Posts: 23,101
    edited 2008-05-15 22:50
    You're really missing a lot of information here, like the declarations for the various instruction operands.
    Assuming that m_ACK is a bitstring for the ACK pin, the first waitpeq will probably not work because the "1"
    probably isn't in the right bit position. I like to use zero all the time for the destination field when it can work,
    so a waitpne 0,m_ACK will continue when ACK is high, then the waitpeq 0,m_ACK will continue when the ACK
    becomes low.
  • nicolad76nicolad76 Posts: 164
    edited 2008-05-15 23:09
    sorry I thought that the information about which pin m_ACK is, it is not relevant for this problem.
    In this case


    m_ACK long |< H_ACK

    where H_ACK is defined as
    H_ACK = 15 in CON section

    I'll try your "method"....
    thanks
  • nicolad76nicolad76 Posts: 164
    edited 2008-05-15 23:44
    well...it didn't work.....I'll keep trying....
  • kuronekokuroneko Posts: 3,623
    edited 2008-05-16 03:08
    andn OUTA,m_DS ' set m_DS (=H_DS) low 
    
    waitpeq 1,m_ACK   ' detect falling edge of m_ACK
    waitpeq 0,m_ACK
    
    or OUTA,m_DS ' set m_DS (=H_DS) high
    



    The first waitpeq is unlikely to work, you may well AND with the right mask (condition is D == (INA & S)) but you compare against register 1. Which - unless you have an absolute branch at location 0, and some constants after that - I doubt is what you intended to do. Note that immediate mode only works with the source operand. So given that register 1 most likely holds some active code (rather than data) the cog will sit there forever.

    I'd suggest something like this (assuming m_ACK being a register with the required bit pattern):

    waitpeq m_ACK, m_ACK  ' wait until (INA & m_ACK) == m_ACK, i.e. ACK pin high
    waitpne m_ACK, m_ACK  ' wait until (INA & m_ACK) != m_ACK, i.e. ACK pin low
    



    HTH

    Post Edited (kuroneko) : 5/16/2008 3:14:38 AM GMT
  • Ken PetersonKen Peterson Posts: 806
    edited 2008-05-16 17:02
    I like kuroneko's approach, and that is what I use myself:
    waitpeq flag, flag ' wait for a high
    waitpne flag, flag ' wait for a low.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • nicolad76nicolad76 Posts: 164
    edited 2008-05-16 20:50
    I'll try and let you know......it looks I didn't understand wait statement at all
  • nicolad76nicolad76 Posts: 164
    edited 2008-05-16 21:52
    it works much better now....actually it works now [noparse]:)[/noparse]

    One last question...how would you implement a timeout on those wait?
  • Mike GreenMike Green Posts: 23,101
    edited 2008-05-16 23:06
    You can't do a timeout in the sense you mean.· You have two options:

    1) If you have an unused I/O pin and a free counter, you can set up the counter to output a high for a period of time, then output a low.· The WAITPEQ or WAITPNE would include that I/O pin in its pattern and that transition would terminate the wait.· The I/O pin doesn't have to be connected to anything since the implicit INA refers to the I/O pin state (which has to be output for the counter to change it).

    2) You could forget the WAITxxx and just have a loop in assembly language that tests for an I/O pin pattern, then tests for a timeout, then loops back to try again.· This takes more power since the cog is running, but it's not a lot of power.
  • nicolad76nicolad76 Posts: 164
    edited 2008-05-18 13:00
    I see...thanks!
Sign In or Register to comment.