Forum: Mikrocontroller und Digitale Elektronik FTDI Baudrate mit Spezial-Divisor berechnen


von Tobias G. (tubias)


Lesenswert?

Hallo

ich habe mir das Interface 38211 von 
http://www.wut.de/e-38211-ww-dade-000.php gekauft. Ich möchte jetzt mit 
einem USB-Sniffer (z.B. http://aspycom.free.fr/) Telegramme von einem 
RS485 Bus mitschneiden. Ich muss ja jetzt dem FTDI FT232R Chip-Treiber 
über die FTDIPORT.INF die Baudrate einstellen. Benötigt wird 1,5Mbit/s.
Divisor ist somit:
3000000 / 1500000 = 2
In dem FTDI-Manual steht das die Divisoren 0 und 2 keine Sub-Integer
haben können. Was muss jetzt in die INF, vor allem in die Sektion
[FtdiPort232.NT.HW.AddReg] eingetragen werden so das der FTDI in dem
Interface auch mit 1,5MBit/s arbeitet? Wie wird das berechnet?

Dann ist mir auch noch nicht ganz klar wie der USB-Controller 
eingestellt werden muss, wegen der Paketgröße usw. Oder kann man dafür 
nicht einfach einen USB-Sniffer verwenden, muss man das mit der D2XX Lib 
machen?


Es währe mir aber schon sehr viel weitergeholfen, wenn mir einer 
erklären könnte wie man das Baudrate Aliasing für den Spezial-Divisor 2 
macht.


mfg
Tobias

von Martin (Gast)


Lesenswert?

Ich denke, du denkst da zu kompliziert. Auf deinem PC stellt das Modul 
eine RS232 Schnittstelle dar. Du brauchst also ein Programm womit du auf 
die "COM"-Schnittstelle zugreifen kannst. Die 1,5MBit/s muss dann nur 
als Schnittstellenparameter angegeben werden (statt 19200kBaud als 
150000kBaud). Dann muss man sich nicht mit den Divisoren des FTDI-Chips 
rumschlagen.

von Tobias G. (tubias)


Lesenswert?

Hi

Man kann aber in den Port Settings der emulierten COM-Schnittstelle max. 
921600 Bit/s einstellen. Ich brauche aber 1500000 Bit/s. Außerdem kann 
es doch auch dadurch das es keine Interrupt gesteuerte COM-Schnittstelle 
ist evtl. zu Datenverlusten kommen, oder?

mfg
Tobias

von ak (Gast)


Lesenswert?

Hallo Tobias!
allgemengültige FTDIPORT.INF
------------------------------------------------------------------------ 
-
HKR,,ConfigData,1,11,00,3F,3F,10,27,00,00,88,13,00,00,C4,09,00,00,E2,04, 
00,00,71,02,00,00,38,
41,00,00,9C,80,00,00,4E,C0,00,00,34,00,00,00,1A,00,00,00,0D,00,00,00,06, 
40,00,00,03,80,00,00,
00,00,00,00,D0,80,00,00
------------------------------------------------------------------------ 
-
Wenn man 1A,00,00,00 durch 02,00,00,00 ersetzt,
kann man mit 1,5MBaud auf USB alles mitsniffen.
In aspycom muss man dann die Baudrate 115200 auswählen.
So wird dem FTDI eine falsche Geschw. vorgespielt:
1A,00,00,00 => divisor = 26, rate = 115,384
02,00,00,00 => divisor = 2, sub-integer prescaler = 0, rate = 1,500,000

Gruss,
ak

von Martin (Gast)


Lesenswert?

> Man kann aber in den Port Settings der emulierten COM-Schnittstelle max.
> 921600 Bit/s einstellen. Ich brauche aber 1500000 Bit/s.

Ich betreibe eine Schaltung von mir mit 1.25MBaud, und das funktioniert.

> Außerdem kann es doch auch dadurch das es keine Interrupt gesteuerte COM-> 
Schnittstelle ist evtl. zu Datenverlusten kommen, oder?

Nein, da die Daten automatisch in einen Puffer geschrieben werden.

von Tobias G. (tubias)


Lesenswert?

Hallo

OK. Jetzt habe ich das kapiert. Mir war bisher Unklar, das man aus den 
Aliasen irgendeinen mit dem neuen Alias ersetzten kann. Man muss dann in 
der Anwendung halt nur den Alias einstellen den man ersetzt hat.
Z.B.: Alias für 300Baud ersetzen:
10,27,00,00 = 10000 = 300Baud -> 1500000 = 2 = 02,00,00,00

oder Alias für 115384 ersetzen:
1A,00,00,00 = 26 = 115384 -> 1500000 = 2 = 02,00,00,00

In der Anwendung wird der ersetzte Alias eingestellt.

Danke!

mfg
Tobias

von Christian R. (supachris)


Lesenswert?

Wenn du das Programm eh selber schreibst, kannst du auch 
nicht-standard-Baudraten einfach einstellen. Zumindest bei C++ geht das.

von Ramiz (Gast)


Lesenswert?

hello
any one can help me and tell me that
01,00,00,00 => divisor = 1, rate = what ?????

if divisor = 1
what is the rate ??

thnx for ur help

von so nicht (Gast)


Lesenswert?

How about setting this divisor, writing to the port and checking the 
baudrate with a scope ?

von Ramiz (Gast)


Lesenswert?

YEs i need to know what is the baudrate for this divisor
if divisore = 1 ?????

thnx for ur help

von Falk B. (falk)


Lesenswert?

@ Ramiz (Gast)

>YEs i need to know what is the baudrate for this divisor
>if divisore = 1 ?????

3 MBaud/s

Regards
Falk

von Ramiz (Gast)


Lesenswert?

when i use baud rate = 3mb i see divisor is 0 !!!!!! not 1
what is the baud rate to make divisor be 1 :(

thnx for ur help

von Falk B. (falk)


Lesenswert?

from the datasheet of the FTDI232R

"Baud Rate = 3000000 / (n + x)

where n can be any integer between 2 and 16,384 ( = 2^14 ) and x can be 
a sub-integer of the value 0, 0.125, 0.25, 0.375, 0.5, 0.625, 0.75, or 
0.875. When n = 1, x = 0, i.e. baud rate divisors with values between 1 
and 2 are not possible."

von Falk B. (falk)


Lesenswert?

@ Ramiz (Gast)

>when i use baud rate = 3mb i see divisor is 0 !!!!!! not 1

How do you do this?

Reagrds
Falk

von B e r n d W. (smiley46)


Lesenswert?

@ Ramiz

If you check www.ftdichip.com for data sheets, you will find this one:

AN232B-05_BaudRates.pdf

Look at page 4

Note: Divisor = 1 and Divisor = 0 are special cases. A divisor of 0 will 
give 3 MBaud, and a divisor of 1 will give 2 MBaud. Sub-integer divisors 
between 0 and 2 are not allowed.

@Falk
He can easily do this by using the ftd2xx.dll and access the chip 
directly.
(When using FTDI's D2XX direct driver the function FT_SetBaudRate can be 
used to set both standard and non-standard baud rates)

Best regards, Bernd

von Ramiz (Gast)


Lesenswert?

thnx for smiley46 and falk and i readed this decoument
but i have problem
i have virtual  and it is use ft 232BM chip
i need to make it read the data from device
and the device use baudrate 2MB/Sec how i can do that ??
cuz when i try to do i see i can not make baudrate for this virtual port 
to 2mb/sec i get bad data

any one can help me on that ?

and thnx for ur help

von B e r n d W. (smiley46)


Lesenswert?

@Ramiz

If you use 1 for the baudrate, it should work very exactly with 2MBit.

But there can be other reasons for your error.

1. Crosstalking between 2 lines, reflections or other unclean signals. 
Two parallel cable, 1 meter long, can have 50 or more pF capcity to each 
other.

2. The buffer size of the FT232BM is 4kByte. To fill the buffer last 
2.048 ms. To empty a full buffer needs at least 1-2 ms, because the USB 
frame time is 1 ms. So probably you get a buffer overrun.

3. Is the baud rate exactly 2,000,000 bit/s or 2Mbit=2,097,152 bit/s? 
The difference is ~5% and probably too much.

Could you reduce the speed and try 115,200 kbaud first?

Bernd

von Ramiz (Gast)


Lesenswert?

plz smiley46
i think u can help me my em ai l is ramizzzzz at gmail . com
i hope u can send to me ur email there to talk with u privet thnx for ur 
help

von B e r n d W. (smiley46)


Lesenswert?

Hello Ramiz

But what is the advantage of using email? Many people are reading this 
and we all together have more ideas than only one. And if we solve the 
problem, it will help others. This is the idea of this forum.

Even a guest like you can attach files/sketches. This should be the next 
step, so we can imagine, how your your system is working. Which drivers 
you use, how long the cables are ...

Question: Which software do you use, to receive the data and how do you 
setup the baudrate? Did you write it by yourself?

Bernd

von Ramiz (Gast)


Lesenswert?

Hello smiley46
i have to device one is use FT 232BM but i connect it as d2xxx and i set 
speed to be 2mb/sec by softwear by ft_baudrate
and i have another Ft 232BM Device But it connect as vcp and when i set 
the baud rate to be 2mb/sec by this command SetCommState(hPort, dcbPort)
i can nnot see the divisor be 1 ???!!!!
i want i connect 2 diveices and i want to make sniff by usb trace in the 
diveice wich use vcp to get the data wich send by divice d2xx ??!! but i 
can not see good data
that is all :(

von B e r n d W. (smiley46)


Lesenswert?

Something is still unclear

You want, that 2 communicate whith each other?
And the third sniffer with vcp?

Or 1 send with d2xx and the other receive with vcp?

Do you know the program Portmon.exe from Sysinternals? It is very 
useful, to look, what a COMx interface is doing. You can download it 
from microsoft.

http://technet.microsoft.com/en-us/sysinternals/bb896644.aspx

Regards

von Ramiz (Gast)


Lesenswert?

Hello
i hope some one can help me
i need to read data from synchronous interface
i can read that data by com port ??

von Hijack (Gast)


Lesenswert?

No, that won't work out.

von B e r n d W. (smiley46)


Lesenswert?

Dear Ramiz

>synchronous interface
Something like a I2C, JTAG or SPI or is this unknown?

Do we still discuss about the same case above?

Probably it could work with a FT2232, which offers:
"a variety of additional new modes of operation including a 
Multi-Protocol Synchronous Serial Engine (MPSSE) interface which is 
designed specifically for synchronous serial protocols such as I2C, JTAG 
and SPI bus".

Bernd

von Jeams (Gast)


Lesenswert?

Hallo zusammen,

ich bin gerade dabei eine platine zu entwickeln  M32 (16 Mhz extern 
getaktet) und FT232RL.Ich schaffe es eine kommunikation mit einer 
baudrate von 115200 problemlos aber das ist zu wenig. Ich muss auf 
250000 mindestens kommen. Ich habe FTDIPORT.INF geändert ´mit den neuer 
Baudrate und die FTDI Treiber noch einmal instaliert das problem ist die 
erwünschte Baudrate nicht steht nicht auf die liste.
was habe ich falsch gemacht?

MFG

von Rufus Τ. F. (rufus) Benutzerseite


Lesenswert?


Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.