Serial objects question
max72
Posts: 1,155
I have used the various serial objects with no big issues in the past, but this time I cannot figure what is not working.
I set up a serial mirror, and I mirror my data to the serial terminal. The other serial thing is a SIM900 GSM module.
When I use the full duplex serial on the GSM side everything works.
If I use the 4 ports full duplex serial (traditional or with extended buffer) I only get back garbage. Probably missing something obvious, but cannot get it. Any suggestion is appreciated.
Using Saleae Logic analyzer I get corret readings setting 115200 bits/sec, 8 bits per trasnfert, 1 stop bit, no parity bit, LSB first, non inverted.
Thanks in advance,
Massimo
test code:
I set up a serial mirror, and I mirror my data to the serial terminal. The other serial thing is a SIM900 GSM module.
When I use the full duplex serial on the GSM side everything works.
If I use the 4 ports full duplex serial (traditional or with extended buffer) I only get back garbage. Probably missing something obvious, but cannot get it. Any suggestion is appreciated.
Using Saleae Logic analyzer I get corret readings setting 115200 bits/sec, 8 bits per trasnfert, 1 stop bit, no parity bit, LSB first, non inverted.
Thanks in advance,
Massimo
test code:
OBJ Debug : "Fullduplexserial" Comm : "FullDuplexSerial" comm2 : "pcFullDuplexSerial4FC" Pub Start debug.start(31,30,0,57600) 'comm.start(18,17,0,115200) comm2.AddPort(0,18,17,-1,-1,0,%0,115200) comm2.start repeat char:=comm2.rxcheck(0) if char == -1 else debug.tx(char) waitcnt(clkfreq/1000+cnt) char:=debug.rxcheck if char == -1 else Comm2.tx(0,char) waitcnt(clkfreq/1000+cnt)
Comments
The good news is that after several hours of frustration, I'll never do that again.
The clock frequency is set. Moreover if I read the data bask with fullduplezserial it works, and at 115200 it cannot be just luck. Same thing when I send data to the module. The logic analyzer says the data is sent reasonably shaped.
I'm breadboarding, so there are connections 10cm/5" long, but I assume fullduplexserial and pcFullDuplexSerial4FC are equivalently picky?
Massimo
Anyway I tried also with 115200 on both serial ports, with the same result.
Massimo
Init does pretty much nothing except call stop
but STOP initializes buffers and pointers???
Massimo
I also tested the prop in pin with a scope, and the signals are sharp and well shaped.
What is the HEX value of the "garbage" char?
What value are you expecting?
How about comparing the logic analyzer results with the garbage char. Are the values equal?
I've never been entirely confident that 115200 is a super reliable comms speed. Back in the olden days (1984) my dad and I ran a cable from upstairs to downstairs to link two computers. The cable was 5 wires and about 30 metres long and we struggled to get anything reliable over 9600 baud. My old 1985 computer even struggled with a 3 metre lead and 19200 baud.
Can you retest with slower baud rates? Could it work with a really slow speed like 1200 baud (I have run 400 metres of unshielded cable at 1200 baud and it works). Or does it have to be 115200?
it could well be related to the fact that I'm close to the rate limits...
@Dr_Acula: the 115200 is the factory setting from the unit. I was trying to leave it alone..
@Mike G: please find full source code and hex readings.
Thanks for you time and the suggestions.
I attached the full source of a new simplyfied version.
It constatly sends "AT" to the serial and reads back the data.
I expect an echo of the data and "OK"
from FDS the hex code is consistent and I get the following:
switching the comments on the comm objects I get not constant readings:
and so on....
Massimo
Is there a way you can measure the bit-widths of the unit you're interfacing to?
Using the results and the fact that more ports are causing less jitter, I added 3 empty UARTS and it now works..