FullDuplexSerial Tx problem
OlovA
Posts: 23
Hi. Does anyone know how to check if the "tx-buffer" is ready to receive new data ?
As it is now, i must wait after two byte of data until i put new data there for transmit.
Maybe i do something wrong...
Thank´s / Olov
As it is now, i must wait after two byte of data until i put new data there for transmit.
Maybe i do something wrong...
Thank´s / Olov
Comments
It's not quite what you asked for. Here's one that waits for some room in the buffer
Note that the "$0F" assumes that the transmit buffer is 16 bytes in length. If you're using some other
buffer size, you'll have to change the constant appropriately.
Post Edited (Mike Green) : 3/1/2009 5:38:00 PM GMT
What i want to do is, receive 8 bytes of Hex-data from pin 10 ( That works )
Then i want to do something with it ofcourse, and send that data back to the host...
If i send it without delay between the byte's, then after 3 byte's it doesn't send anymore.
But if i insert a delay in the transmission routine it work's ( But then i get timeout at the host-side )
I'll try to attach two pic's so u might understand what's happening...
With FullDuplexSerial, your "Fail" program should work. I don't know how you've connected the PC to the Propeller.
From the "485" in the names of your pictures, I suspect that you're trying to use a half duplex RS485 setup to
communicate. If so, you have to wait for the transmit buffer to empty before "turning the line around", then you
have to wait for the transmit routine in the assembly cog to finish transmitting the last byte itself. You can approximate
that by waiting until the transmit buffer is empty, then wait around 1 to 1.5 character times. Essentially use the "txflush"
routine I showed, then wait (with WAITCNT) around 200us for the last character to be transmitted.
I didn't think of the Tx Cog like that! When u told me it maked the coin fall down ( Swedish to english translation !!! )
But anyway, yes that's it. Now it works like it should do. Again, MANY thank's Mike. From a snowy and cold Sweden / Olov.