|
|
View previous topic :: View next topic |
Author |
Message |
ljb
Joined: 19 Nov 2003 Posts: 30
|
rs232 not working at 115k2bd baud. |
Posted: Wed Oct 11, 2006 6:14 am |
|
|
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
|
|
|
asmallri
Joined: 12 Aug 2004 Posts: 1635 Location: Perth, Australia
|
|
Posted: Wed Oct 11, 2006 6:46 am |
|
|
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
|
|
Posted: Wed Oct 11, 2006 7:21 am |
|
|
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
|
|
Posted: Wed Oct 11, 2006 8:00 am |
|
|
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: 1635 Location: Perth, Australia
|
Re: rs232 not working at 115k2bd baud. |
Posted: Wed Oct 11, 2006 8:49 am |
|
|
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!! |
|
|
|
|
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
|