|
|
| Author |
Message |
DH* Guest
|
|
Posted: 09 January 2006, 13:51 PM Post subject: Feature Request |
|
|
| I would like to have a version of WaitForInterrupt that has a timeout parameter. |
|
| Back to top |
|
 |
mikep
Joined: 24 Sep 2005
Posts: 765
Location: Austin, TX
|
|
Posted: 09 January 2006, 14:19 PM Post subject: |
|
|
In the meantime there is another way of doing what you want.
Typically you would do a WaitForInterrupt() inside a separate task so you don't hold up the mainline processing. Application note AN209 (http://www.zbasic.net/appNotes/AN209.pdf) describes how to resume a task. I haven't tried it but I'm sure this will work for WaitForInterrupt(). |
|
| Back to top |
|
 |
DH* Guest
|
|
Posted: 09 January 2006, 14:45 PM Post subject: |
|
|
I had already read AN209 before posting my request. I still prefer a timeout (preferably with an optional jump to a label).
My app was written a few years ago for the original BX-24. I couldn't afford the overhead associated with multiple tasks so never really explored the possibilities.
The additional RAM of the ZX-24 might make multi-tasking more attractive but I have other uses for that extra RAM. |
|
| Back to top |
|
 |
dkinzer Site Admin
Joined: 03 Sep 2005
Posts: 2499
Location: Portland, OR
|
|
Posted: 09 January 2006, 16:18 PM Post subject: |
|
|
An extended version of WaitForInterrupt() is on the enhancement list. The form it would most likely take is something similar to the optional timeout on GetQueue(), e.g.
| Code: | | WaitForInterrupt(trigger, intNum, timeLimit, timeoutFlag) |
|
|
| Back to top |
|
 |
DH* Guest
|
|
Posted: 09 January 2006, 17:01 PM Post subject: |
|
|
Thanks, Don.
NetMedia added that to GetQueue at my request but I would have preferred an optional jump to label rather than the TimeOut flag.
On a related subject InputCapture is only useful if you know in advance how many transitions to expect. I'd like an Ex version with min/max values that would cause it to exit, again with a jump to label. |
|
| Back to top |
|
 |
dkinzer Site Admin
Joined: 03 Sep 2005
Posts: 2499
Location: Portland, OR
|
|
Posted: 09 January 2006, 18:00 PM Post subject: |
|
|
| Quote: | | NetMedia added that to GetQueue at my request but I would have preferred an optional jump to label rather than the TimeOut flag. |
I suspect that they chose not to implement "jump to label" because of its decidedly unstructured nature. That would be my argument against it as well. If you prefer a GoTo, you can easily implement that by testing the flag. The only advantage that I can see to the "jump to label" implementation is that it would be slightly faster.
On the other hand, designing the API with an implicit GoTo requires everyone to use the unstructured approach. Additionally, although it probably isn't a concern for the BasicX compiler, unstructured control elements like GoTo, Exit, etc. complicate optimization analysis and limit optimization opportunities. |
|
| Back to top |
|
 |
DH* Guest
|
|
Posted: 09 January 2006, 20:28 PM Post subject: |
|
|
| Quote: | | The only advantage that I can see to the "jump to label" implementation is that it would be slightly faster. |
And maybe take slightly less code. I was looking for every byte I could possibly save since I was up against the limits. |
|
| Back to top |
|
 |
DH* Guest
|
|
Posted: 13 January 2006, 16:12 PM Post subject: |
|
|
| Quote: | | The only advantage that I can see to the "jump to label" implementation is that it would be slightly faster. |
Slightly faster might be critical in some instances.
| Code: | For n = 0 To bits
Register.TCCR1A = 0 'reset Timer1
Register.TCNT1H = 0
Register.TCNT1L = 0
Register.TIFR = bx0000_0100 'TOV1
Register.TCCR1B = 2 'start Timer1
Call WaitForInterrupt(1)
'THERE MAY NOT BE TIME TO TEST FOR TIMEOUT HERE
PulseTrain(n) = MakeWord(Register.TCNT1L, Register.TCNT1H)
If (PulseTrain(n) < 800) Or (PulseTrain(n) > 4000) Then
Exit Sub
End If
Next |
|
|
| Back to top |
|
 |
|