With external ISRs enabled, debug.print of course locks up the system until characters are placed onto the queue.
A consequence is that interrupts are serviced at arbitrary times, whenever debug.print gives control back.
Is there a better way to output debug info to the screen that doesn't conflict with infrequent (~500Hz) ISR calls? Such as manually copying single characters into the queue, etc., when the system is free.
Debug.print and interrupts
Re: Debug.print and interrupts
I just checked the code to confirm that interrupts are not disabled for Debug.Print. It is true, however, that calling Debug.Print will cause an interrupt for each character sent. It is possible that those interrupts will cause the servicing of an external interrupt to be deferred.pjc30943 wrote:debug.print [...] locks up the system until characters are placed onto the queue.
The code below can be used in place of Debug.Print to print a single string. Note that you have to manually add the CRLF. The commented-out call to Sleep() in the loop can be used to throttle back the speed of outputting the characters. This may be helpful in reducing the deferral of servicing of the external interrupt.pjc30943 wrote:Is there a better way to output debug info to the screen that doesn't conflict with infrequent (~500Hz) ISR calls? Such as manually copying single characters into the queue, etc., when the system is free.
Code: Select all
Sub OutStr(ByVal s as String)
Dim outQueue() as Byte Based Register.TxQueue
Dim strLen as Integer, idx as Integer
strLen = Len(s)
For idx = 1 to strLen
' wait for space to be available
Do While (GetQueueSpace(outQueue) <= 0)
' Call Sleep(0.1)
Loop
' output the next character
Dim c as Byte
c = Asc(s, idx)
Call PutQueue(outQueue, c, 1)
Next idx
End Sub
Sub Main()
OutStr("Hello, world!" & Chr(&H0d) & Chr(&H0a))
End Sub
- Don Kinzer