[futurebasic] [FB] problem in receiving serial data

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : February 2006 : Group Archive : Group : All Groups

From: "Dott. Bernardi" <lbern1ps@...>
Date: Fri, 24 Feb 2006 16:03:19 +0100 (NFT)
Hi to all!

I need to connect my Mac to a PIC microcontroller, and I am tryiig to use
the serial port , via a Maxxtro  USB-serial interface.

Below there is a sample of the program I am trying to use.

The all thing works without mistakes when I use a very low baud rate (say
300). The more I increase the rate the higher is the chance of curruption
of the data I am receiving.

For example, using 57600 baud, I have generated a frequency of 57470 baud
with my microcontroller, but the data sent are very often corrupted.

The situation improves a little if I drop the rate down to about 55500Hz,
but the problem remains.

I have checked the ACTUAL transmission rate of my mac, and I have found
that, when I declare 57600  I actually get 55970. The same order of
imprecision remains with lower baudrates (eg 9424 instead of 9200 and so
on).

Could someone help in finding a way to obtain a reliable data reception at
a baudrate of 57600 or (even better) 115200 baud ?

Many thanks
Luciano

-------------------------------example of code for receiving serial data

icount%= 0
nloop%=300

' _____________________________________set serial port
thisPort% = _printerPort

OPEN "C", thisPort%, 57600,_noParity,_oneStopBit,_eightBits,4096

HANDSHAKE thisPort, _none



do
    do
         READ# thisPort%, b$;0
     until len(b$)


    inc(icount%)
    a$(icount%) =b$

until icount%= nloop%

CLOSE thisPort%

for icount%=1 to nloop%
print a$(icount%);
next


INPUT "--";z%

END