PDA

View Full Version : how to work with timing?



nicolad76
05-15-2008, 06:50 PM
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 :)

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!!!

Ken Peterson
05-15-2008, 07:30 PM
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?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔

nicolad76
05-16-2008, 05:17 AM
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 Green
05-16-2008, 05:22 AM
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).

nicolad76
05-16-2008, 05:28 AM
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 Green
05-16-2008, 05:50 AM
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.

nicolad76
05-16-2008, 06:09 AM
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

nicolad76
05-16-2008, 06:44 AM
well...it didn't work.....I'll keep trying....

kuroneko
05-16-2008, 10:08 AM
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 Peterson
05-17-2008, 12:02 AM
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.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔

nicolad76
05-17-2008, 03:50 AM
I'll try and let you know......it looks I didn't understand wait statement at all

nicolad76
05-17-2008, 04:52 AM
it works much better now....actually it works now :)

One last question...how would you implement a timeout on those wait?

Mike Green
05-17-2008, 06:06 AM
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.

nicolad76
05-18-2008, 08:00 PM
I see...thanks!