View previous topic :: View next topic |
Author |
Message |
Guest
|
Another RS232 issue |
Posted: Wed Dec 14, 2005 3:46 pm |
|
|
Hi guys,
I have been reading the posts, but haven't seen anything like my problem.
I am using a 16F873A and a 20 MHz Osc and I am trying to communicate with the PC through rs232 (I use a MAX232 too).
I have a simple test program that counts every 1 second and shows the value of the counter on the screen.
The problem is that the communication (at least TX from the pic to the pc) works fine at first, for the first few seconds, but then it goes nuts and starts sending garbage for a while, and then it stops throwing anything.
It displays:
counter = 1
counter = 2
counter = 3
counter = 4
�W–‹…)��•��…)�MY‹…)
...and then it just stops communicating.
I have tried to run some of the example codes that come with the compiler and tried copying some of the codes that appear at the manual, but always get the same problem: rs232 communication works for some seconds and then it just goes nuts.
Any ideas of what can the problem be?
Thanks in advance! |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Dec 14, 2005 3:51 pm |
|
|
Quote: | I have a simple test program that counts every 1 second and
shows the value of the counter on the screen. |
Post the test program. Be sure to pPost all the #include, #fuses, and
#use statements.
Also post your compiler version. |
|
|
Guest
|
|
Posted: Wed Dec 14, 2005 4:15 pm |
|
|
Here it is:
#include <16F873A.h>
#include <stdio.h>
#include <stdlib.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, PARITY=N, BITS=8,ERRORS)
void main() {
int a=0;
while (TRUE) {
++a;
printf("counter = ");
printf("%d \n", a);
delay_ms(1000);
}
}
I use PCWH 3.203.
Perhaps there is a very obvious mistake, but I just can't find. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Dec 14, 2005 4:25 pm |
|
|
What terminal program are you using ?
What operating system are you using on your PC ?
Do you have fifo buffers enabled for your PC's COM port ? |
|
|
Humberto
Joined: 08 Sep 2003 Posts: 1215 Location: Buenos Aires, La Reina del Plata
|
|
Posted: Wed Dec 14, 2005 4:42 pm |
|
|
I looks like a power fault or something consuming extra current.
1) Did you check the input voltage before the +5V regulator ?
2) Did you check the voltages at MAX232:
PIN2 to Gnd = ?? ( +V )
PIN6 to Gnd = ?? ( -V )
I would check them before and after the errors.
Humberto |
|
|
Guest
|
|
Posted: Wed Dec 14, 2005 7:56 pm |
|
|
PCM programmer, I am working on a pc with windows 98, and I am using the "serial port monitor" which is in the tools of the compiler. I also tried downloading another serial port monitor, but it didn't work either.
Humberto, I think the hardware part is ok, but I will check those values tomorrow (I don't have the tools for doing it right now), and see what happens. Thanks. |
|
|
Guest
|
|
Posted: Wed Dec 14, 2005 7:57 pm |
|
|
PCM programmer, I am working on a pc with windows 98, and I am using the "serial port monitor" which is in the tools of the compiler. I also tried downloading another serial port monitor, but it didn't work either.
Humberto, I think the hardware part is ok, but I will check those values tomorrow (I don't have the tools for doing it right now), and see what happens. Thanks. |
|
|
Guest
|
|
Posted: Thu Dec 15, 2005 8:12 am |
|
|
Sorry for the duplicate message, it was a browser problem.
Now I used Hyperterminal to monitor the port, and I have the same problem. I have fifo buffers enabled. |
|
|
|