Chip resets on serrxd (timeout?)

Grant Fleming

Senior Member
My 40X1 resets after about a minute (the timeout I suppose) if the PICAXE receives nothing. I read in the manual that setting the timeout and address to go to on a timeout is 'optional'. I do not wish to have a time limit, just want it to wait for the user's input.
How do I go about this?

Cheers
Grant
 

MORA99

Senior Member
If you do not set a timeout and label it defaults to 65seconds and returns to line 1

so make a label at the serrxd instead

:ser
serrxd [60000,ser] ...
 

Grant Fleming

Senior Member
Thanks MORA99
My programme now works a treat!
I re-read the page from the manual many times but couldn't seem to get my syntax right. Thanks again,
Grant
 

hippy

Technical Support
Staff member
<i>If you do not set a timeout and label it defaults to 65seconds and returns to line 1 </i>

That is entirely non-intuitive behaviour if that is how it works and definitely needs explaining clearly in the manual.

I would have assumed ( and would expect other sto ) that if there was no timeout specified, the command would wait in SERIN forever until data did arrive, not that it did timeout and restart the program.

That waiting may be achieved by setting a 65 second timeout with a jump back to the SERIN command itself ( which is what the hacked solution forces ), which is what I thought the compiler would have dropped in there if nothing was specified.

If the program does restart from the beginning of the code, what happens when the SERIN is within an interrupt which hasn't re-enabled interrupts ? A normal GOTO out of an interrupt routine in such a case would prevent interrupts from ever responding again.

If the SERIN does restart the program when there is no timeout specified, this breaks compatibility between X1 and non-X1 parts; the very same source code runs differently on each, and that's very wrong IMO.

I think we need a clear statement from Technical on exactly what the behaviour should be when no timeout is specified.
 

hippy

Technical Support
Staff member
A further point to note ...<code><pre><font size=2 face='Courier'> #picaxe18x
SerIn 0,N2400,(&quot;ABC&quot;),b0 </font></pre></code> is not the same as...<code><pre><font size=2 face='Courier'> #picaxe28x1
Self : Serin [65535,Self], (&quot;ABC&quot;),b0 </font></pre></code> In the first case the code works even if the b0 data arrives an hour after &quot;ABC&quot;, in the second case, b0 must be sent within 65 seconds of &quot;ABC&quot;. It's similar if any single SerIn command is reading mutliple data bytes which may have long time periods between them ...<code><pre><font size=2 face='Courier'> #picaxe18X
SerIn 0,N2400,b0,b1

#picaxe28x1
Self : SerIn [65535,Self],0,N2400,b0,b1 </font></pre></code> If one sent &quot;0, wait an hour, 1, 2, wait an hour, 3, 4 etc&quot; the PICAXE-18X would return b0/b1 pairs of &quot;0/1&quot;, &quot;2/3&quot;, the 28X1, pairs of &quot;1/2&quot;, &quot;3/4&quot;.

For operational compatibility across the entire PICAXE range, the compiler cannot simply fake a missing timeout to be 65 seconds with a jump to the same SerIn. The firmware really has to do absolutely nothing except keep waiting when no timeout is specified.

Edited by - hippy on 13/08/2007 13:32:22
 

Grant Fleming

Senior Member
Hi Hippy,
Yes, this had me stumped for quite some time, especially since the manual stated that the timeout was 'optional' - I would have thought that it just waited until data arrived by default if no timeout specified. It did go to the first line in my programme after this 'auto-timeout'.
Cheers,
Grant
 

tarzan

Senior Member
This has been fixed in version 5.1.5 release of the Programming Editor.
Pervious post: <A href='http://www.rev-ed.co.uk/picaxe/forum/topic.asp?topic_id=7246&amp;forum_id=10&amp;Topic_Title=Serrxd+b0+%26%238216%3Btimes+out%21&amp;forum_title=Software+Feedback&amp;M=False' Target=_Blank>External Web Link</a>
 

Grant Fleming

Senior Member
Thanks Tarzan,
I didn't realise there was a V5.5
I only just downloaded V5.4 a couple of weeks ago!
Will download it and try it out.
Cheers,
Grant
 

hippy

Technical Support
Staff member
We still need to know what &quot;Fixed&quot; equates to ...

1) SERIN behaves exactly as it did on non-X1 parts when no timeout is specified and SERRXD behaves as if it were a SERIN on the SI pin using N4800, or

2) SERIN / SERRXD behave as [65535,Self] when no timeout is specified.

As previously described, there is a considerable difference between the two in particular cases, no matter how esoteric those particular cases may be.

If the command is restarted after 65 seconds, it would never be possible to write code for an X1 which behaved exactly as it did on a non-X1 as data could arrive while the timeout was re-loading the SerIn command, timeout, pin and baud rate and miss or corrupt the data received which a non-X1 would not.

That could present a problem for anyone waiting for any byte of data which could turn up at any time. Sod's law dictates your data arrives just as SSERIN/SERRXD decides to do something other than wait for the character.
 

tarzan

Senior Member
Hi Hippy

I understand your concerns that you have outlined and can only say that Technical will have to put them to rest. I have not done any extensive testing to verify one-way or the other. I only say &#8220;fixed&#8221; as that is what Technical said they would do. Anyhow over to Technical. <img src="wink.gif" width=15 height=15 align=middle>
 
Top