View previous topic :: View next topic |
Author |
Message |
Sebastian.Heyn
Joined: 13 Apr 2005 Posts: 86
|
Posted: Tue Nov 10, 2015 3:31 pm Post subject: wait for print to finish |
|
|
Hey guys,
maybe a quick question
Howto wait for print buffer to empty?
do
loop until Ucsra.txc=1
doesnt seem to do the job.
Is there a bascom internal variable i can use??
(BASCOM-AVR version : 2.0.7.8 ) |
|
Back to top |
|
|
i.dobson
Joined: 05 Jan 2006 Posts: 1570 Location: Basel, Switzerland
|
Posted: Tue Nov 10, 2015 6:50 pm Post subject: |
|
|
Hello,
The Compiler creates the following variables, I imagine you could check if _RS_BUFCOUNTW1 is 0 or not. Note the 1 is comm port 2.
Code: |
_RS232OUTBUF1 Byte(254) 014B 331
_RS_HEAD_PTRW1 Byte 0249 585
_RS_TAIL_PTRW1 Byte 024A 586
_RS_BUFCOUNTW1 Byte 024B 587
|
Regards
Ian Dobson _________________ Walking on water and writing software to specification is easy if they're frozen. |
|
Back to top |
|
|
MWS
Joined: 22 Aug 2009 Posts: 2262
|
Posted: Tue Nov 10, 2015 7:56 pm Post subject: Re: wait for print to finish |
|
|
Sebastian.Heyn wrote: | do
loop until Ucsra.txc=1
doesnt seem to do the job. |
Understandable, as TXC is already set from the previous transmit. To make TXC properly work, it needs to be cleared every time before data is written to UDR.
You can't alter the normal Print to behave this way, but you can use Config Print, which is used for RS485 and similar purpose.
Normally for RS485 a port-pin is toggled after transmission is complete, but also a dummy variable will work, however you have to provide something.
You don't even need to check this variable, as Print is altered by Config Print the way, that it only returns after the transmission is complete.
Code: | Dim dummy As Byte
Config Print = dummy.0 , Mode = Set |
|
|
Back to top |
|
|
Sebastian.Heyn
Joined: 13 Apr 2005 Posts: 86
|
Posted: Thu Nov 12, 2015 8:51 am Post subject: |
|
|
Thanks for pointing this out.
Is there a more complete documentation? I never saw this config print before?? |
|
Back to top |
|
|
olhexy
Joined: 03 Apr 2011 Posts: 192 Location: Tilburg, Netherlands
|
Posted: Thu Nov 12, 2015 12:08 pm Post subject: |
|
|
I was just thinking about BEFORE and AFTER when print to LCD. http://avrhelp.mcselec.com/index.html?config_lcd.htm
Printing to lcd or to serial is not very different.
May be that BEFORE...AFTER does not work for serial. But it could be easy(?) made to work like LCD, I suppose.
I was thinking again... may be you could print something to LCD as a dummy to make use of BEFORE and AFTER. (Not a nice solution) |
|
Back to top |
|
|
MWS
Joined: 22 Aug 2009 Posts: 2262
|
Posted: Thu Nov 12, 2015 3:19 pm Post subject: |
|
|
Sebastian.Heyn wrote: | Is there a more complete documentation? |
You don't like the info in the help file?
Quote: | I never saw this config print before?? |
Maybe you never used hardware handshake and RS-485.
Many times it's easier to suggest a solution for a certain demand, than to use tricks on an existing command.
What exact purpose should this serve for?
One valid purpose I can imagine, is to be sure everything is sent, before going into sleep-mode.
But that can be also done with a waitms.
The trick with the variable for not wasting a pin is something I can tell you, as I can read and test the disassembly.
But it is not a guaranteed feature, it can change in the future and you won't find it in the manual, aka help, this way. |
|
Back to top |
|
|
|