News:

Let's find out together what makes a PIC Tick!

Main Menu

Fast Serin?

Started by dr-zin, Sep 27, 2022, 09:36 PM

Previous topic - Next topic

dr-zin

Hello all.  A quick question.  The Positron manual (8) says that the command accommodates most transfer speeds up to 38.4 kBaud.  That is normally fine, as I rarely use faster than 9600.  However, I need to communicate with a sealed module that is hard-coded to transmit only at 115,200 baud.  Is this even possible with this command and a standard PIC (say 16F887) running at 20 MHz?  I presume not, but I wanted to ask first before trying more devious means.

Are there faster commands to use?  Will a hardware connection buy me anything?  Is there an assembly code plug-in that will receive this quickly?  Any answers (even of stuff to rule out) would be helpful.  Thanks.

dr-zin

For clarity, sunglass face appears where I tried to put the numeral 8 in parentheses.  I was referring to the 8-bit manual.

RGV250

Hi,
Using PIC Multi calc gives these settings for a hardware serial, it is an old program so probably needs declare in front or something.

RCSTA = $90 ' Enable serial port & continuous receive
TXSTA = $24 ' Enable transmit, BRGH = 1
SPBRG = 10  ' 115200 Baud @ 20MHz, -1.36%

Bob

Yasin

If what you want is to increase the speed of software serial communication. By doing some manipulations, you can go up to 96000bps with the serin/serout commands. If you set xtal=4 and baudrate 19200bps (baudmode=32) and connect a 20mhz crystal to the mcu, it will communicate at 96000bps.

top204

#4
The Serin and Serout commands are a throwback to the old BASIC Stamp II module, and their maximum Baud is 38400. The Rsin and Rsout commands are also software based, so they cannot reach high Baud rates either because of the very fast delays required alongside the code to handle the bits.

For high Baud rates, use the device's USART (common name UART), and the HSerin or HSerout or HRsin or HRsout commands, and the Declare so setup their Baud rate. i.e. Declare HSerial_Baud = Baud Rate

dr-zin

So, high baud rate is possible using hardware uart commands, but is probably device specific.  That is good to know...
In the meantime, the device also has a RS-485 port where I can coax out some of the same information at a whopping 4800 baud.  That will be the preferred route for now, but glad to know that high throughput is possible if needed.

Thanks all.  Cheers!

John Lawton

Yes, a UART can be fast, I have successfully received/sent 460,800 Baud serial data with an 18F26K22 and the Xtal set to 64MHz. At such a high Baud rate if you need to do a lot of processing of the data you may need the high clock speed. In this case I also employed a 1024 byte interrupt driven circular input buffer as I was receiving serial data packets over ethernet.

tumbleweed

Software UARTs can be very problematic, especially if used to receive data or with programs that use interrupts.

If you want something reliable, switch to the hardware ones.