CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

rs232 not working at 115k2bd baud.

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
ljb



Joined: 19 Nov 2003
Posts: 30

View user's profile Send private message

rs232 not working at 115k2bd baud.
PostPosted: Wed Oct 11, 2006 6:14 am     Reply with quote

Hi,
Does anybody have any ideas why the following code does not work at 115k2bd or 57k6bd. It works fine at 38k4bd and lower.
The ext xtal is dead on 8mhz (measured with a freq counter).
I have had the 2620 outputing data to hyperterminal at 115k2 in the past, but for some reason even this simple code doesn't work.
very confused!!!
Les
Storic



Joined: 03 Dec 2005
Posts: 182
Location: Australia SA

View user's profile Send private message Send e-mail

PostPosted: Wed Oct 11, 2006 6:27 am     Reply with quote

check this link http://www.ccsinfo.com/forum/viewtopic.php?t=26786 Shocked

Andrew
_________________
What has been learnt if you make the same mistake? Wink
asmallri



Joined: 12 Aug 2004
Posts: 1634
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Wed Oct 11, 2006 6:46 am     Reply with quote

ljb wrote:
Hi,
Does anybody have any ideas why the following code does not work at 115k2bd or 57k6bd. It works fine at 38k4bd and lower.
The ext xtal is dead on 8mhz (measured with a freq counter).
I have had the 2620 outputing data to hyperterminal at 115k2 in the past, but for some reason even this simple code doesn't work.
very confused!!!
Les


Are you driving the pIC at 32MHz (HSPLL fuse) or 8MHz? Also you forgot to post your code.
_________________
Regards, Andrew

http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!!
ljb



Joined: 19 Nov 2003
Posts: 30

View user's profile Send private message

PostPosted: Wed Oct 11, 2006 7:21 am     Reply with quote

Oop's the code is below.
I have had a look at the link from the reply above, and the problem is very similar if not the same. I have version 2.349, would any later versions cure this?

//------System------

#include <18F2620>
#fuses intrc_io,NOWDT,NOPROTECT,NOMCLR,NODEBUG,NOLVP

#use delay(clock=8000000)



//------serial streams------

#use rs232(baud=115200, xmit=PIN_C4, rcv=PIN_C3, errors,stream=monitor)


main()
{
while(true){
fprintf(monitor,"heello\r\n");
delay_ms(200);
}
}
Guest








PostPosted: Wed Oct 11, 2006 8:00 am     Reply with quote

I posted in another thread some time ago, about just how fast you might expect the software serial to go. At 115200bps, using a 8MHz master clock, you have just 17 instruction times between each bit of the data. Now the software serial, inside each bit time, has to update and test the bit counter, rotate the integer involved, read or write the corresponding bit, delay to get the right timing, and loop. The total loop, written in assembler, comes out at perhaps 13 instructions.
I'd actually have expected 57600 to work, but would not be suprised for 115200 to fail. However a quick look at the generated listing, shows that the compiler is correctly optimising the delay, down to single 'nops' at the higher rate, and is in fact getting the timing 'right', just about as close as it can be.
The compiler version mentioned, does not make sense. 2.349, wouldn't have supported the 2620 chip. 3.249, is really the latest 'reasonably working' compiler.
If you have a scope, as well as a DFM, then measure the actual bit time, and word time for a character. You can adjust the actual timings used, by 'cheating' the clock/baud value. However the low number of instructions/byte, imply that the 'steps' will be large, with something over a 6% change between possible timings...

Best Wishes
asmallri



Joined: 12 Aug 2004
Posts: 1634
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

Re: rs232 not working at 115k2bd baud.
PostPosted: Wed Oct 11, 2006 8:49 am     Reply with quote

ljb wrote:
Hi,
Does anybody have any ideas why the following code does not work at 115k2bd or 57k6bd. It works fine at 38k4bd and lower.
The ext xtal is dead on 8mhz (measured with a freq counter).
I have had the 2620 outputing data to hyperterminal at 115k2 in the past, but for some reason even this simple code doesn't work.
very confused!!!
Les


115200 from a software UART at 8Mhz is a tough ask. I assume you cannot use the hardware UART. Is this a low power application or can you use the internal PLL to get the FOSC to 32MHz?
_________________
Regards, Andrew

http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!!
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group