I think now my problems are with the COM ports. My project uses COM 1 at 9600, COM 3 at 9600, and COM 4 at 19200. I was able to get it to work on the ZX-24r, but not with the native mode device. If I limit it to COM 1 & 3, I can get it to sort of work, but the watchdog times out too fast. When I add COM 4, I get no output.
The test code I am trying for the serial ports is below
Code: Select all
Option SignOn Off
Private Com1OutQ(1 to 30) as Byte
Private Com1InQ(1 to 10) as Byte
Private Com3OutQ(1 to 30) as Byte
Private Com3InQ(1 to 10) as Byte
Private Com4OutQ(1 to 30) as Byte
Private Com4InQ(1 to 10) as Byte
Public Sub Main()
Call ComChannels(2, 19200)
Call OpenQueue(Com1OutQ, SizeOf(Com1OutQ))
Call OpenQueue(Com1InQ, SizeOf(Com1OutQ))
Call OpenQueue(Com3OutQ, SizeOf(Com3OutQ))
Call OpenQueue(Com3InQ, SizeOf(Com3OutQ))
Call OpenQueue(Com4OutQ, SizeOf(Com4OutQ))
Call OpenQueue(Com4InQ, SizeOf(Com4OutQ))
Call DefineCom(3, 20, 19, bx0000_1000)
Call DefineCom(4, 18, 13, bx0000_1000)
Call OpenCom(1, 9600, Com1InQ, Com1OutQ)
Call OpenCom(3, 9600, Com3InQ, Com3OutQ)
Call OpenCom(4, 19200, Com1InQ, Com1OutQ)
Call PutPin(Pin.RedLED, 0)
Call PutQueueStr(Com1OutQ, "COM 1 OUT")
Call PutQueueStr(Com3OutQ, "COM 3 Out")
Call PutQueueStr(Com4OutQ, "COM 4 Out")
Call PutPin(Pin.RedLED, 1)
Call PutPin(Pin.GreenLED, 0)
Dim i As Integer
Dim sMsgOut As String
'Flash On-Chip LEDs at startup
For i = 1 To 2
delay 0.15
Call putpin(25, 0)
delay 0.15
Call putpin(25, 1)
delay 0.15
Call putpin(26, 0)
delay 0.15
Call putpin(26, 1)
Next
'=================
sMsgOut = "startup"
Call PutQueueStr(Com1OutQ, sMsgOut)
' prepare for "Standby" sleep mode
Register.SMCR = &H06
' set up the WatchDog for interrupt mode with a 4 second timeout
Atomic
' the first assignment enables change, the second configures
Register.WDTCSR = Register.WDTCSR Or &H18
Register.WDTCSR = &He0
End Atomic
Do
' output a message, wait for all chars to be sent
sMsgOut = "sleeping"
Call PutQueueStr(Com1OutQ, sMsgOut)
Do While CBool(StatusCom(1) And &H04)
Loop
' go to sleep
Call CPUSleep()
sMsgOut = "awakened"
Call PutQueueStr(Com1OutQ, sMsgOut)
Call WatchDog()
Loop
End Sub
' WatchDog timer interrupt service routine
ISR WDT()
' nothing to do
End ISR
'==============================================================================