News:

PROTON pic BASIC Compilers for PIC, PIC24, dsPIC33

Main Menu

Serout command time

Started by hitronics, May 23, 2021, 05:41 PM

Previous topic - Next topic

hitronics

I am just curious to know when using Serout command sending 8 bytes on baud rate 2400 or 9600 so want to know how many microseconds takes

trastikata

1 000 000 * 8 * 1/9600 = 833.3 uS

hitronics

Quote from: trastikata on May 23, 2021, 05:47 PM1 000 000 * 8 * 1/9600 = 833.3 uS

that is brilliant
how about Serin command?

trastikata

I just saw you said bytes not bits ... so 8x longer.  In-out - the same.

If you are asking how many instructions takes the command itself, you have to check the assembler file and count the cycles.

TimB


tumbleweed

#5
For a uart, in addition to the number of data bits you also have to include the start, parity (if used), and stop bit(s).

So, for 9600 N81 (no parity, 8 data, 1 stop) the time = (1 + 8 + 0 + 1) x (1/9600) = 1.04ms (1040us) per byte
Likewise, 2400 N81 = 10 x (1/2400) = 4.16ms (4160us) per byte

For 8 bytes, just multiply the above. That gives you the minimum time, assuming back to back transfers.

RayEllam

A little trick I learned many moons back. IF you have an oscilloscope then set an unused pin high before the procedure and low after it. Read the exact timing on your scope...... easy and no counting machine cycles in ASM 😎

top204

After a short while, the bit times for serial transmission are second nature and certain, commom, Baud rate bit times stick in the memory. i.e. 104uS and 7uS. So once these are known, it is just a matter of multiplying them or dividing them by other Baud values to get the bit times. :-)

Also, as Tumbleweed pointed out, standard UART serial coms consist of 10-bits, not 8-bits. There is the Start and Stop bits to take into account, both using the same bit speeds.