RS232 communication with 32 MHz
Moderator: Benj
- Jan Lichtenbelt
- Posts: 797
- Joined: Tue Feb 17, 2009 8:35 pm
- Location: Haren GN, the Netherlands
- Has thanked: 128 times
- Been thanked: 264 times
- Contact:
RS232 communication with 32 MHz
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
Can someone helps me?
Kind regards
Jan Lichtenbelt
-
- Posts: 594
- Joined: Thu Sep 17, 2009 7:52 am
- Location: Belgium
- Has thanked: 63 times
- Been thanked: 102 times
- Contact:
Re: RS232 communication with 32 MHz
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
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
- Jan Lichtenbelt
- Posts: 797
- Joined: Tue Feb 17, 2009 8:35 pm
- Location: Haren GN, the Netherlands
- Has thanked: 128 times
- Been thanked: 264 times
- Contact:
Re: RS232 communication with 32 MHz
Dear Nicolas,
How can I test if the data are correctly sent, other then with a receiver?
Jan Lichtenbelt
How can I test if the data are correctly sent, other then with a receiver?
Jan Lichtenbelt
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: RS232 communication with 32 MHz
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
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
Martin
- Jan Lichtenbelt
- Posts: 797
- Joined: Tue Feb 17, 2009 8:35 pm
- Location: Haren GN, the Netherlands
- Has thanked: 128 times
- Been thanked: 264 times
- Contact:
Re: RS232 communication with 32 MHz
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
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
- Jan Lichtenbelt
- Posts: 797
- Joined: Tue Feb 17, 2009 8:35 pm
- Location: Haren GN, the Netherlands
- Has thanked: 128 times
- Been thanked: 264 times
- Contact:
Re: RS232 communication with 32 MHz
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.
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.
- Attachments
-
- RS232.xls
- (13.5 KiB) Downloaded 257 times
-
- Posts: 594
- Joined: Thu Sep 17, 2009 7:52 am
- Location: Belgium
- Has thanked: 63 times
- Been thanked: 102 times
- Contact:
Re: RS232 communication with 32 MHz
You could use a logic analyzer or a PC scope that has a built in analyzer.Jan Lichtenbelt wrote:Dear Nicolas,
How can I test if the data are correctly sent, other then with a receiver?
Jan Lichtenbelt
- Jan Lichtenbelt
- Posts: 797
- Joined: Tue Feb 17, 2009 8:35 pm
- Location: Haren GN, the Netherlands
- Has thanked: 128 times
- Been thanked: 264 times
- Contact:
Re: RS232 communication with 32 MHz
Please find the oscilloscope picture of two microcontrollers, both sending the character "1"
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
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
- Jan Lichtenbelt
- Posts: 797
- Joined: Tue Feb 17, 2009 8:35 pm
- Location: Haren GN, the Netherlands
- Has thanked: 128 times
- Been thanked: 264 times
- Contact:
Re: RS232 communication with 32 MHz
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
Does someone has the C-program for me for this auto-baud detect?
Kind regards
Jan Lichtenbelt