Page 1 of 1
RS232 communication with 32 MHz
Posted: Sat Jun 23, 2012 7:35 pm
by Jan Lichtenbelt
I use the 12F1840 which does have only 8 pins. I have to work at maximum speed of 32 MHz. To debug the program I send with RS232 (Tx only) to an other microcontroller (Rx only) which shows the data on LCD. I send both strings and numbers. But up to now, I do not succeed in showing all RS232 data correct.
Can someone helps me?
Kind regards
Jan Lichtenbelt
Re: RS232 communication with 32 MHz
Posted: Sun Jun 24, 2012 2:23 am
by Spanish_dude
Hi Jan,
Have you tried to look at the data sent from your 12F PIC ? Does it send every byte you want him to send correctly ?
If so, then it's probably something wrong with the receiver.
Nicolas
Re: RS232 communication with 32 MHz
Posted: Sun Jun 24, 2012 9:30 am
by Jan Lichtenbelt
Dear Nicolas,
How can I test if the data are correctly sent, other then with a receiver?
Jan Lichtenbelt
Re: RS232 communication with 32 MHz
Posted: Sun Jun 24, 2012 10:00 am
by medelec35
The issue to me sounds like Buad rate may be out a bit.
So to answer your question:
What I do is send U (must be upper case)
I then measure with a scope, or just lately been using Test pod which is ideal!
If you set to trigger on negative edge pulse then the baud rate is 1/time duration of pulse.
If you have a waveform measuring device and would like to post results we maybe able to take it from there.
I will try at 32MHZ and send strings, and see if I can assist you further by suggesting setting you may be able to tweak.
Is is software or hardware generated RS232?
Also you tried sending directly to comms on PC to chech tx side rather than a separate microcontroller?
Martin
Re: RS232 communication with 32 MHz
Posted: Sun Jun 24, 2012 12:17 pm
by Jan Lichtenbelt
Dear Martin
1) I use software RS232, because 12F1840 does not have the hardware available. (Correction later on: It is available)
2) I will try the scope.
3) The sender12F1840 works at the internal 32 MHz oscillator (not exact I think). The receiver can not use this frequency, because the LCD does not work any more (all delays times will be reduced a factor 2 at 32 MHz). The receiver has to work at 16 MHz.
Can it be that the deviation of the exact frequencies (32MHz sender, 16 MHz receiver) can give problems with correct receiving data? My only results up to now were with 38400 baud for the sender and 19200 baud for the receiver. Lower values failed. I do not know why.
But the 38400 baud rate does not work under Flowcode V5 (see elsewhere). So I had to go down to 19200 respectively 9600 baud rates.
Kind regards
Jan Lichtenbelt
Re: RS232 communication with 32 MHz
Posted: Sun Jun 24, 2012 1:37 pm
by STibor
If the LCD display is slow, initialize more than once.
Re: RS232 communication with 32 MHz
Posted: Sun Jun 24, 2012 2:22 pm
by Jan Lichtenbelt
Dear Martin,
Please find my measurements of the RS232 outputs
Time Time Time
RS232 RS232 PIC calculated measured difference
PIC baud frequ frequ osc. usec usec %
16F690 4800 19660800 19660800 ext. 208 214 2,7
16F690 4800 19660800 8000000 int 512 516 0,8
12F1840 4800 19660800 32000000 int 128 130 1,6
All measured values within the accuracy of an oscilloscope.
The repeating time is 10x the values above. That means that the deviation of about 2% will not give wrong results?
Kind regards
Jan Lichtenbelt
PS. the layout of the table is lost. Therefor I added the better xls attachment.
Re: RS232 communication with 32 MHz
Posted: Sun Jun 24, 2012 2:36 pm
by Spanish_dude
Jan Lichtenbelt wrote:Dear Nicolas,
How can I test if the data are correctly sent, other then with a receiver?
Jan Lichtenbelt
You could use a logic analyzer or a PC scope that has a built in analyzer.
Re: RS232 communication with 32 MHz
Posted: Sun Jun 24, 2012 2:45 pm
by Jan Lichtenbelt
Please find the oscilloscope picture of two microcontrollers, both sending the character "1"

- Sending 1 upper_ 4800 baud with 32Mhz and lower_ 19200 baud with 8 MHz_t.jpg (196.48 KiB) Viewed 7161 times
1)UPPER: 12F1840 32 MHz int. oscillator, 4800 baud
2)LOWER: 16F690 8 MHz int. oscillator, 19200 baud
Pay attention: The third peak just in the middle is no peak at all (just introduced by triggering problems).
This seems workable settings to me. Now the flowcode program.
Kind regards
Jan Lichtenbelt
Re: RS232 communication with 32 MHz
Posted: Sun Jun 24, 2012 4:30 pm
by Jan Lichtenbelt
Perhaps I have to use the RS232 hardware with auto-baud detect.
Does someone has the C-program for me for this auto-baud detect?
Kind regards
Jan Lichtenbelt