View previous topic :: View next topic |
Author |
Message |
young
Joined: 24 Jun 2004 Posts: 285
|
Why there is some data duplicated during rs232 communication |
Posted: Wed Dec 01, 2004 4:01 pm |
|
|
My Rs232 communicated well, but with a problem, that is sometimes, it output more result than I expect, like
printf("%u \r\n",data);
the hyperterminal print out \0A 234 \0D
occasionally print out \0A 234 234 \0D, or \0A 234 4\0D.
what might cause this problem? |
|
|
young
Joined: 24 Jun 2004 Posts: 285
|
|
Posted: Wed Dec 01, 2004 4:11 pm |
|
|
I put a delay after printf; it looks everything is fine. maybe I am seding data too fast?
IN low baud rate, I need a long delay, in high baud rate, may not need delay, it depends. |
|
|
Haplo
Joined: 06 Sep 2003 Posts: 659 Location: Sydney, Australia
|
|
Posted: Wed Dec 01, 2004 4:21 pm |
|
|
Is your printf() in a loop? Post more of your code. |
|
|
young
Joined: 24 Jun 2004 Posts: 285
|
|
Posted: Wed Dec 01, 2004 4:26 pm |
|
|
Thank you: here is the main ()
Code: |
main()
{
while(1)
{
set_adc_channel( 0 );
delay_us(50);
temperature = Read_ADC();
delay_ms(50);
printf("%u \r\n",temperature,);
}
}
|
by the way, another question, how to printf int32
for int8 a;
int 16 b;
is
printf("%u %lu", a,b); |
|
|
Haplo
Joined: 06 Sep 2003 Posts: 659 Location: Sydney, Australia
|
|
Posted: Wed Dec 01, 2004 4:47 pm |
|
|
Well I'd say you were pumping out data so fast the the PC was missing characters. That made it look like duplicated data. A delay should take care of it as you said.
For int32 also use %lu. |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Wed Dec 01, 2004 7:01 pm |
|
|
This isn't the first post where you have had problems with receiving chars to your PC. I'd look at the connections, MAX232 chip, cable, or even try another PC. And don't use Hyperterminal, in sucks! |
|
|
MGP
Joined: 11 Sep 2003 Posts: 57
|
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Wed Dec 01, 2004 9:59 pm |
|
|
I just cannot believe that Windows still includes it! |
|
|
CharlieGill
Joined: 29 Nov 2004 Posts: 15 Location: northeast georgia
|
|
Posted: Thu Dec 02, 2004 6:09 am |
|
|
Thanks for the tips on a Hyperterminal replacement. I've never liked it but have just been to lazy I guess to go looking for a replacement.
I downloaded Bray Terminal as TeraTerm had it's last update in 99. I grinned when I saw the VT100 support. I wonder how many people these days even know what a VT100 was...ah the good old days. Well I guess they probably wern't all THAT good, 4K, asembler, cassettes, TV monitors, yuk. Still I miss the light and switches of the old control panels sometimes.
Charlie |
|
|
|