serial connection with propeller
newmi
Posts: 7
hi
i have a problem.
im using the propeller in combination with the netburner from parallax.
there is a serial connection between the 2 boards (using the FullDuplexSerial object). the communication from the propeller to the netburner works perfect. the same with communication between a pc and the netburner. but i cant recieve data with the propeller. i get random data i think, if connected with the netburner, and i get nothing, if connected with a pc.
here a piece of spin-code:
this is my "answer code"
i dont think that here is the problem ! Because i can interact with the netburner and a pc as i want to !
thanks
i have a problem.
im using the propeller in combination with the netburner from parallax.
there is a serial connection between the 2 boards (using the FullDuplexSerial object). the communication from the propeller to the netburner works perfect. the same with communication between a pc and the netburner. but i cant recieve data with the propeller. i get random data i think, if connected with the netburner, and i get nothing, if connected with a pc.
here a piece of spin-code:
OBJ sio: "FullDuplexSerial" PUB func sio.start(0,1,3,7800) waitcnt(cnt+10000000) sio.str(@welcome) 'works perfect. waitcnt(cnt+1000000) string2:=" " rxbuf:=" " repeat while rxbuf<>43 'the answer has to be "you are welcome+", so i want to have "hallo+" in string2 rxbuf:=sio.rx waitcnt(cnt+10000000) sio.tx(43) 'for debugging reasons i echo the incoming byte. string2+=rxbuf 'via netburner i get ² or ascii nr.3 or something like that. repeat 'with a pc connected, i get no answer waitcnt(cnt+1) DAT welcome byte "PROP-ROBOTART+" rxbuf byte string2 byte "hallo",0
this is my "answer code"
i dont think that here is the problem ! Because i can interact with the netburner and a pc as i want to !
int fdserial = OpenSerial(1,2400,1,8,eParityNone); buff=""; while (buffer[noparse][[/noparse]0]!='+'){ read(fdserial, buffer, 1); buff=buff+buffer[noparse][[/noparse]0]; } if(!registered && buff=="PROP-ROBOTART+"){ //anmeldung iprintf("Prop-RobotArt tries to log in\n"); write(fdserial, "you are welcome+",16); iprintf("Prop-RobotArt is welcome\n"); registered=true; } while (1){ read(fdserial, buffer, 1); iprintf("%c",buffer); }
thanks
Comments
first thing I see is that the propeller-code uses a buadrate of 7800 really strange
your answercode in c uses a baudrate of 2400 that does not fit. They have to have both the same baudrate
in your propellercode the prop runs with the internal oscillator at 11-13 MHz. This gives no accurate timing you have to add
the following lines at the top of your code
which will setup the clock of the prop to 80MHz
bbest regards
Stefan
i use:
_CLKMODE = XTAL1 + PLL16X
_XINFREQ = 16_000_000
and 7800 is 2400*3,2.
in the original code the _XINFREQ = 5_000_000, so 16_000_000 is 3,2*5_000_000.
sio.str() and sio.tx() works perfect. thats not the problem.
but, anyway. thx
hope for more reactions [noparse]:D[/noparse]
It is not posible to run Propeler with that frequency
In my tests last reliable frequency is Crystal 14.318.180 from old PC VGa kort and
not posible to run it with PLL16x. With 15MHz Crystal and PLL8x Propeler have problem and not posible to run it with PLL16x
_CLKMODE = XTAL1 + PLL8X
_XINFREQ = 14_318_180
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Nothing is impossible, there are only different degrees of difficulty.
For every stupid question there is at least one intelligent answer.
Don't guess - ask instead.
If you don't ask you won't know.
If your gonna construct something, make it·as simple as·possible yet as versatile as posible.
Sapieha
i'll try another freq tomorrow. thx
I bet the problems were caused by your overclocking
what would happen in the worst case if you use
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000 ????
what serious reason do you have to use
_clkmode = xtal1 + pll16x
_xinfreq = 16_000_000 ????
256 MHz is far outside from specification !!
best regards
Stefan
but nothing changed. i have still the same problem.
send data works, receiving doesnt [noparse]:([/noparse]
what do i do wrong?
1) is it intended that you invert the TX line, but not the RX ? (you've set mode 2 = %0010 at sio.start).
2) Spin does not support String handling in the way you use it in the first example (string2 += rxbuf). You have to work with byte arrays for strings (something like string2[noparse][[/noparse]i++] := rxbuf) and the string2 must be declared big enough for the max. possible length.
Andy