View previous topic :: View next topic |
Author |
Message |
Gabriel Caffese
Joined: 09 Oct 2003 Posts: 39 Location: LA PLATA, ARGENTINA
|
Silly question about RS232 speed and times |
Posted: Fri Feb 27, 2004 5:09 pm |
|
|
Hello everyone,
I´ve managed to communicate an 16F628 with a PC, at 115200.
It downloads a 24LC256 eeprom full of sampled data from certain sensor.
While the 16F628 is sending data, it doesn´t do other tasks.
It gets 33 - 34 seconds to download all data, so, aprox. 1kb second.
Sholudn´t it be more than this ??
115200b/sec / 11b is aprox = 15200bytes/sec
Or am I doing something wrong ??
Thanks in advance.- |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Feb 27, 2004 6:35 pm |
|
|
Quote: | It gets 33 - 34 seconds to download all data, so, aprox. 1kb second.
Sholudn´t it be more than this ?? |
It takes time to read the bytes from the EEPROM.
If you use the CCS function, read_ext_eeprom(), it will take
approximately 50 bits of i2c transmission just to read one byte.
The 16F628 does not have a MSSP module, so you have to
use software i2c.
The CCS software routines probably do not run at 100 KHz.
Here is some information from an old post of mine.
I think these tests were done with vs. 2.7xx of the compiler.
4 MHz crystal = 40 KHz i2c clock
8 MHz crystal = 62.5 KHz i2c clock
10 MHz crystal = 80 KHz i2c clock
Let's say you're using a 20 MHz crystal. Then you can probably
get the full 100 KHz standard i2c clock speed. To do 50 bits
on the i2c bus, would take 50/100,000 = .5 ms.
So this is where your delay is coming from.
You can eliminate most of this delay by using the "Sequential Read"
mode with the 24LC256. You just need to write a routine to use
that method, instead of the read_ext_eeprom() function. |
|
|
Humberto
Joined: 08 Sep 2003 Posts: 1215 Location: Buenos Aires, La Reina del Plata
|
|
Posted: Fri Feb 27, 2004 6:50 pm |
|
|
Hola Gabriel,
Assuming 8N1 you get:
(1/115200) * 10 = 0.000086 sec/byte
Max room for 24LC256 = 32768 bytes
32768 bytes * 0.000086 sec/byte = 2.8180 sec
That´s the minimum theorical data transfer time, you didn't post your code so may be you need to re-check it.
Also you will check with a scope your xtal freq and the bit width in Tx line.
regards,
Humberto |
|
|
Gabriel Caffese
Joined: 09 Oct 2003 Posts: 39 Location: LA PLATA, ARGENTINA
|
Thanks a lot ! |
Posted: Fri Feb 27, 2004 11:35 pm |
|
|
PCM Programmer,
Thank you very much. I´working at 4Mhz. Uhhh !!!
I´ve thought it would be an EEPROM speed limit that may be causing it, but never thought I2C "soft transfer" speed would be as low as 40Khz !
Humberto,
Gracias. El problema evidentemente está en que el bus I2C lo implemento por software, y la velocidad de transferencia es extremadamente baja. De Capital ? Yo estoy en La Plata.
Thank you both.- |
|
|
|