JMLStamp2p
01-23-2008, 09:33 PM
Good Morning,
I want to start a new cog to run the Recieve Method in my program and need help understanding a few things. I want the new Cog to monitor Pin "1"·in a constant loop where I have a tranciever in-putting Serial data. I understand that I need to be concerned about Stack space but un-clear how to code. Once I recieve a byte of data and compare that byte to "$01" in my PUB Recieve Method I want to call a·Transmit Method to output some data.
Other Questions:
1) Does rxbyte "located in FullDuplexSerials PUB rx Method " hold the Hex·· byte recieved and pass that byte back to my calling routine so that It can be compared ?
NOTE: See Recieve·Method below.
2) Once I call the Stop Method does this clear the Stack space that the "Recieve" Cog uses ?
.................................................. ......................
My Code Below:
.................................................. ......................
CON
·_CLKMODE = XTAL1 + PLL1X
·_CLKFREQ = 5_000_000·········
.................................................. .......................
OBJ
·DELAY: "Clock"
·DATA: "FullDuplexSerial"
.................................................. ........................
VAR
·long Stack [9]
·byte rxbyte
.................................................. .........................
PUB MAIN
·dira[0]~~
·dira[17]~~
·dira[1]~
·data.start(1,0,2,9600)
·Stop
·Success := (Cog := cognew(Recieve(Pin), @Stack) + 1)
·Recieve
.................................................. ..........................
PUB Stop
··if Cog
·· cogstop(Cog~ - 1)
·Main
.................................................. ..........................
PUB Recieve
·data.rx············
·· If rxbyte :=··$01
·····Transmit
·· Recieve
.................................................. ..............................................
PUB Transmit
·data.tx ($22)
·!outa[17]
·Stop····················· 'Calls the Stop Method to stop the "Recieve" Cog.
.................................................. ...............................................
Any suggestions on how to condense this code would be appreciated.
Regards.
John.
·
I want to start a new cog to run the Recieve Method in my program and need help understanding a few things. I want the new Cog to monitor Pin "1"·in a constant loop where I have a tranciever in-putting Serial data. I understand that I need to be concerned about Stack space but un-clear how to code. Once I recieve a byte of data and compare that byte to "$01" in my PUB Recieve Method I want to call a·Transmit Method to output some data.
Other Questions:
1) Does rxbyte "located in FullDuplexSerials PUB rx Method " hold the Hex·· byte recieved and pass that byte back to my calling routine so that It can be compared ?
NOTE: See Recieve·Method below.
2) Once I call the Stop Method does this clear the Stack space that the "Recieve" Cog uses ?
.................................................. ......................
My Code Below:
.................................................. ......................
CON
·_CLKMODE = XTAL1 + PLL1X
·_CLKFREQ = 5_000_000·········
.................................................. .......................
OBJ
·DELAY: "Clock"
·DATA: "FullDuplexSerial"
.................................................. ........................
VAR
·long Stack [9]
·byte rxbyte
.................................................. .........................
PUB MAIN
·dira[0]~~
·dira[17]~~
·dira[1]~
·data.start(1,0,2,9600)
·Stop
·Success := (Cog := cognew(Recieve(Pin), @Stack) + 1)
·Recieve
.................................................. ..........................
PUB Stop
··if Cog
·· cogstop(Cog~ - 1)
·Main
.................................................. ..........................
PUB Recieve
·data.rx············
·· If rxbyte :=··$01
·····Transmit
·· Recieve
.................................................. ..............................................
PUB Transmit
·data.tx ($22)
·!outa[17]
·Stop····················· 'Calls the Stop Method to stop the "Recieve" Cog.
.................................................. ...............................................
Any suggestions on how to condense this code would be appreciated.
Regards.
John.
·