Calling FullDuplexSerial with different parameters.
Hello all, The Code below is working but wanted advise on calling FullDuplexSerial. I am calling it initially with data.start(1,0,2,9600)·
and then later in PUB LCD_Recieve with parameters as data.start(3,2,0,19200). Is this going to cause problems somewhere else later on as
I learn more and my code gets more complicated ? I am communicating between two Propellers via trancievers on each. The transmitting end sends a "1" and the recieving end replys back with a "1" which jumps to LCD_Recieve. LCD_Recieve·then calls FullDuplexSerial with a different Baud rate·and different parameters.
........................................
My Code below:
........................................
CON
·_CLKMODE = XTAL1 + PLL8X···
·_XINFREQ = 5_000_000········
VAR
·long Stack[noparse][[/noparse]9]
·byte Temp
·
OBJ
·DELAY: "Clock"
·DATA: "FullDuplexSerial"
...........................................................................................
PUB Main
·dira[noparse][[/noparse]16]~~
·dira[noparse][[/noparse]23]~~
·data.Stop················· · 'Stop any outside call to the OBJ data
·data.start(1,0,2,9600)·· 'Set-up Serial Protocall
············································ 'to handle tranciever communication on
·········································· · 'pins 0 & 1 @ 9600 Baud
·Power_up_Reset········· · · 'Power-on reset transmission via Cog-0
·Recieve······················· ·'Cog-0 jumps to handle the Recieve Method
·...........................................................................................
PUB Power_up_Reset
· waitcnt(160_000_000 + cnt)·· 'Wait 2-Sec's after power-on to ...
· !outa[noparse][[/noparse]16]························· ·· 'Togle LED-16
· waitcnt(30_000_000 + cnt)
· !outa[noparse][[/noparse]16]
· waitcnt(30_000_000 + cnt)
· data.tx(1)···························'(1) is the reset code sent out the tranciever
..........................................................................................
PUB Recieve | rxbyte
· repeat
······················
··· rxbyte := data.rx
··· if rxbyte == 1
····· LCD_Recieve··
·················
··· if rxbyte == 2······················································
····· Data_Recieved_2
····
··· if rxbyte == 4············
····· Data_Recieved_4
..................................................
·
PUB LCD_Recieve | rxbyte
·dira[noparse][[/noparse]3]~····························
·dira[noparse][[/noparse]2]~~
·················
· data.start(3,2,0,19200)············'Call to FullDuplexSerial but with
·························································'different parameters & Baud rate
· data.tx(254)········································ · ' Command prefix
· data.tx(88)·········································· · ' Command to clear screen
· data.str(string(" Sloss Industries", 13, 10))
· data.str(string("Quenching Station", 13, 10))
· data.str(string("Instrument Shop", 13, 10))
.................................................................................................
···············
·
and then later in PUB LCD_Recieve with parameters as data.start(3,2,0,19200). Is this going to cause problems somewhere else later on as
I learn more and my code gets more complicated ? I am communicating between two Propellers via trancievers on each. The transmitting end sends a "1" and the recieving end replys back with a "1" which jumps to LCD_Recieve. LCD_Recieve·then calls FullDuplexSerial with a different Baud rate·and different parameters.
........................................
My Code below:
........................................
CON
·_CLKMODE = XTAL1 + PLL8X···
·_XINFREQ = 5_000_000········
VAR
·long Stack[noparse][[/noparse]9]
·byte Temp
·
OBJ
·DELAY: "Clock"
·DATA: "FullDuplexSerial"
...........................................................................................
PUB Main
·dira[noparse][[/noparse]16]~~
·dira[noparse][[/noparse]23]~~
·data.Stop················· · 'Stop any outside call to the OBJ data
·data.start(1,0,2,9600)·· 'Set-up Serial Protocall
············································ 'to handle tranciever communication on
·········································· · 'pins 0 & 1 @ 9600 Baud
·Power_up_Reset········· · · 'Power-on reset transmission via Cog-0
·Recieve······················· ·'Cog-0 jumps to handle the Recieve Method
·...........................................................................................
PUB Power_up_Reset
· waitcnt(160_000_000 + cnt)·· 'Wait 2-Sec's after power-on to ...
· !outa[noparse][[/noparse]16]························· ·· 'Togle LED-16
· waitcnt(30_000_000 + cnt)
· !outa[noparse][[/noparse]16]
· waitcnt(30_000_000 + cnt)
· data.tx(1)···························'(1) is the reset code sent out the tranciever
..........................................................................................
PUB Recieve | rxbyte
· repeat
······················
··· rxbyte := data.rx
··· if rxbyte == 1
····· LCD_Recieve··
·················
··· if rxbyte == 2······················································
····· Data_Recieved_2
····
··· if rxbyte == 4············
····· Data_Recieved_4
..................................................
·
PUB LCD_Recieve | rxbyte
·dira[noparse][[/noparse]3]~····························
·dira[noparse][[/noparse]2]~~
·················
· data.start(3,2,0,19200)············'Call to FullDuplexSerial but with
·························································'different parameters & Baud rate
· data.tx(254)········································ · ' Command prefix
· data.tx(88)·········································· · ' Command to clear screen
· data.str(string(" Sloss Industries", 13, 10))
· data.str(string("Quenching Station", 13, 10))
· data.str(string("Instrument Shop", 13, 10))
.................................................................................................
···············
·
Comments
If you really want to have two serial ports, you can declare two objects, both "FullDuplexSerial". The compiler will include only one copy of the object code and will create two data areas, each around 70 bytes. When running, each object will use a cog for the assembly routine to run and they'll function completely independently.
Post Edited (Mike Green) : 2/8/2008 5:33:04 PM GMT
JMLStamp2p
John.
How about something like this in the OBJ section:
Ya, too simple?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Harley Shanko
JMLStamp2p