FullDuplexSerial "rx" Question
Good Evening,
The code listed below works with a remote transciever transmitting the values "$01" and "$04". When I install the line··" repeat while rxbyte := (1)·" my LED "18"·toggles. If I change the line to "·repeat while rxbyte := (0)·" The LED stops toggling and my transmitter starts outputting "$01" &
"$04" as shown in the code below.
My Question is this:
I want to compare the number recieved by FullDuplexSerials "rx" Method
with a certain value and then jump to a method contingent upon what number is recieved. Could someone Please Edit the code below to help me
accomplish this.
Thanks,
JMLStamp2p
John.
............................................................................................
My Program Below:
............................................................................................
CON
·_CLKMODE = XTAL1 + PLL1X····· 'External crystal 5MHZ times "1"
·_CLKFREQ = 5_000_000········· '5 Million cycles per second
VAR
·byte rxbyte
·byte byte_recieved
OBJ
·DELAY: "Clock"
·DATA: "FullDuplexSerial"
..................................
PUB Main····
·················
·dira[noparse][[/noparse]0]~~
·dira[noparse][[/noparse]1]~
·dira[noparse][[/noparse]16]~~
·dira[noparse][[/noparse]17]~~
·dira[noparse][[/noparse]18]~~
·dira[noparse][[/noparse]20]~~
·'data.Stop
·data.start(1,0,2,9600)
·Recieve
·'Transmit
..........................................................................................
PUB Recieve
· data.rx······················· 'FullDuplexSerial recieve byte
·
· repeat while rxbyte := (1)······ 'Repeat while rxbyte is True or "1"
···· waitcnt(5_000_000 + cnt)
····· !outa[noparse][[/noparse]18]
······· waitcnt(5_000_000 + cnt)
· data.rxflush····················· ' Flush the recieve buffer
· Transmit·······
..........................................................................................
·
PUB Transmit
·waitcnt(5_000_000 + cnt)
·data.tx($01)
·waitcnt(5_000_000 + cnt)
·data.tx($04)
·Main
·
The code listed below works with a remote transciever transmitting the values "$01" and "$04". When I install the line··" repeat while rxbyte := (1)·" my LED "18"·toggles. If I change the line to "·repeat while rxbyte := (0)·" The LED stops toggling and my transmitter starts outputting "$01" &
"$04" as shown in the code below.
My Question is this:
I want to compare the number recieved by FullDuplexSerials "rx" Method
with a certain value and then jump to a method contingent upon what number is recieved. Could someone Please Edit the code below to help me
accomplish this.
Thanks,
JMLStamp2p
John.
............................................................................................
My Program Below:
............................................................................................
CON
·_CLKMODE = XTAL1 + PLL1X····· 'External crystal 5MHZ times "1"
·_CLKFREQ = 5_000_000········· '5 Million cycles per second
VAR
·byte rxbyte
·byte byte_recieved
OBJ
·DELAY: "Clock"
·DATA: "FullDuplexSerial"
..................................
PUB Main····
·················
·dira[noparse][[/noparse]0]~~
·dira[noparse][[/noparse]1]~
·dira[noparse][[/noparse]16]~~
·dira[noparse][[/noparse]17]~~
·dira[noparse][[/noparse]18]~~
·dira[noparse][[/noparse]20]~~
·'data.Stop
·data.start(1,0,2,9600)
·Recieve
·'Transmit
..........................................................................................
PUB Recieve
· data.rx······················· 'FullDuplexSerial recieve byte
·
· repeat while rxbyte := (1)······ 'Repeat while rxbyte is True or "1"
···· waitcnt(5_000_000 + cnt)
····· !outa[noparse][[/noparse]18]
······· waitcnt(5_000_000 + cnt)
· data.rxflush····················· ' Flush the recieve buffer
· Transmit·······
..........................................................................................
·
PUB Transmit
·waitcnt(5_000_000 + cnt)
·data.tx($01)
·waitcnt(5_000_000 + cnt)
·data.tx($04)
·Main
·
Comments
regards
Gerry
JMLStamp2p.
Also, don't use inappropriate recursion!
Thanks,
JMLStamp2p
rxbyte := data.rx
There are various methods:
rx waits until a byte is received
rxcheck returns immediatly with the received byte or -1 of nothing received
rxtime is like rxcheck but waits some milliseconds for a byte.
T send a byte call the tx methode:
data.tx(txbyte)
A Echo Loop:
Hope this helps
Andy
Thank You very much for posting this example. I will try this and if I have any questions I will reply.
JMLStamp2p
Everything is working fine, I can't thank you enough.
It is greatly appreciated !
JMLStamp2p