View previous topic :: View next topic |
Author |
Message |
SB
Joined: 15 Jan 2004 Posts: 10
|
Pic18f458 serial rate problem |
Posted: Mon Jan 19, 2004 3:32 am |
|
|
Does anyone know if I can run a PIC18F458 with a 20Mhz ocs at 115200 baud rate?
When I printf a sting I get lost characters when viewed with hyperterminal. |
|
|
Pete Smith
Joined: 17 Sep 2003 Posts: 55 Location: Chester, UK
|
Re: Pic18f458 serial rate problem |
Posted: Mon Jan 19, 2004 4:03 am |
|
|
SB wrote: | Does anyone know if I can run a PIC18F458 with a 20Mhz ocs at 115200 baud rate?
When I printf a sting I get lost characters when viewed with hyperterminal. |
That could be a Hyperterminal problem. I use Teraterm instead (Google for it - I've lost the URL).
FWIW, to get a zero error on the baud rate, choose a baud rate that's a multiple of 2 of your baud rate.
For 115200 baud at ~20MHz, I'd suggest 18.432MHz. (160x the desired rate).
HTH
Pete. |
|
|
SB
Joined: 15 Jan 2004 Posts: 10
|
|
Posted: Mon Jan 19, 2004 5:06 am |
|
|
Thanks for your suggestion but I get the same result using Teraterm so thats not it.
Also I don't have any problems with other baud rates which have greater error percentages. |
|
|
Ttelmah Guest
|
Re: Pic18f458 serial rate problem |
Posted: Mon Jan 19, 2004 5:48 am |
|
|
SB wrote: | Does anyone know if I can run a PIC18F458 with a 20Mhz ocs at 115200 baud rate?
When I printf a sting I get lost characters when viewed with hyperterminal. |
'Lost characters'?. Obviously, if there was an error in baud rate, you would expect 'garbaged' characters, rather than 'lost' characters. If the characters are completely 'lost', then there are two possibilities. The first is that the PIC is not sending them, while the second is that the PC is failing to receive them. There is no reason for the former (provided everything is the same and working at lower rates), since though the output dats rate rises, most of the register timings, will be slightly easier (for transmit), at the higher rate. Again if there was a signalling problem, you would expect that there would be a tendency to corrupted characters, rather than complete loss.
Before blaming the PIC, try putting a DVM, or scope on the PC's 'handshake' lines, and enabling hardware handshaking in the UART settings box. Also make sure you have the FIFO's enabled here. You may well find that the PC is the problem, and you may need to implement hardware handshaking in both directions (assuming you are going to want the PIC to receive a response). Unfortunately, the latency time of PC's to interrupts is very poor indeed. If you are sending a reasonably long stream of characters, even quite powerful machines can end up losing characters. This is why fast UART cards for the PC, have hardware buffers of often 256 or more characters.
I have suffered in the past, from being able to receive data continuously, at 500000bps, with a really old Z80 based microcontroller, but the same data losing 20 or 30% of characters, when reception was tried on a PC, with a clock that is nominally over 100* faster!...
Best Wishes |
|
|
SB
Joined: 15 Jan 2004 Posts: 10
|
|
Posted: Mon Jan 19, 2004 6:09 am |
|
|
Sorry I did mean to say 'garbaged' characters. |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Mon Jan 19, 2004 6:56 am |
|
|
Are you using a serial cable or something that you made? Are you using the hardware UART on the pic? |
|
|
SB
Joined: 15 Jan 2004 Posts: 10
|
|
Posted: Mon Jan 19, 2004 7:28 am |
|
|
I am using a bought serial cable and using..
#use rs232(baud=115200, xmit=PIN_C6, rcv=PIN_C7) |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Mon Jan 19, 2004 7:30 am |
|
|
Are you using an RS232 transceiver chip? |
|
|
SB
Joined: 15 Jan 2004 Posts: 10
|
|
Posted: Mon Jan 19, 2004 7:49 am |
|
|
Yes we are using a MAX232. We use this same design on another board using a 18F452 which works great at 115200 baud. |
|
|
|