| Posted: 09:08am 19 Jun 2024 |
|
|
|
Hi all, I'm having some issues when running the PICO serial ports at high speed using MMBASIC 5.08.00. The system I've setup comprises 4 RP2040-zeros numbered PICO#0 to PICO#3. I'm using all 4 ADCs on each PICO to digitise 16 analogue signals with PICOs #1-3 sending their data to PICO#0 using multidrop on COM1 (with delays so there's no data collision). PICO#0 connects to a computer via its USB port so the 16 ADC readings can be saved. I'll skip most of the details but to get the speed I require I'm using 921600 baud multidrop between PICOs #1-3 and PICO#0 and I'm also sending data from PICO#0 to the computer via its USB port at 921600 baud. I do have time to run at 460800 baud but not much slower but the problem still appears - I lose the occasional character in the data transfer. I've narrowed it down to comms between a PICO and PICO#0.
So to check what's happening I setup a simple system using 2 raspi PICOs as shown:
 PICO#1's COM1 Tx line is connected to PICO#0's Rx line. The options on both are: OPTION CASE UPPER OPTION AUTORUN ON
The first test I performed was to send a string of 32 characters (plus cr/lf) 10 times per second to the computer via PICO#1's USB port (921600 baud). It runs very well and doesn't drop any characters. I moved the USB cable over to PICO#0 and ran the same test - all good.
Then I loaded the following program into PICO#1 ie it sends 32 characters at 10Hz to PICO#0:
SETPIN GP1,GP0,COM1 OPEN "COM1:921600" AS #5 dat$= "12345678901234567890123456789012" DO PRINT #5,dat$; PAUSE 100 LOOP
In PICO#0 I run the following program ie it collects the 32 bytes from PICO#1 and sends it to the computer:
SETPIN GP1,GP0,COM1 OPEN "COM1:921600" AS #5 DO inp$=INPUT$(70,#5) DO LOOP UNTIL LOC(#5)>=32 inp$=INPUT$(70,#5) PRINT inp$ LOOP
Note that I use the first inp$=INPUT$(70,#5) line to clear the input buffer before waiting for the next 32 bytes. I use 70 in both INPUT statements since the INPUT command reads what's in the input serial buffer even if it's less than 70. 70 is large enough to allow for over two 32 byte strings. What I get is the occasional hiccup. I let TeraTerm run continuously and at random times I see the following:

If I replace the PRINT statement in PICO#0 with
IF LEN(inp$)<>32 THEN PRINT inp$
I get lines printed roughly a minute or so apart as follows (ignore the first line since the program needs to sync first):

I've checked the serial line with a CRO and I can't see any change to the length of the data packet being sent by PICO#1 so I can only assume PICO#0 isn't keeping up with receiving data at that speed.
Any ideas? |