|
|
View previous topic :: View next topic |
Author |
Message |
Markdem
Joined: 24 Jun 2005 Posts: 206
|
RS232 problem |
Posted: Fri Feb 17, 2006 3:51 am |
|
|
Hi All, i have done this a 100's of times, but this time it is not working, and am not to sure why. I am using a MAX232 driver, and have made sure that hardware is OK. when ever i run it, the led will flash, but no output from rs232. Can anyone see what i have done wrong
Thanks, Mark
Code: |
#include <16F88.h>
#FUSES NOWDT, INTRC_IO, NOPUT, NOMCLR, NOBROWNOUT, NOLVP, NODEBUG, NOPROTECT, NOFCMEN, NOIESO
#use delay(clock=4000000)
#use rs232(baud=2400,parity=N,bits=8,xmit=PIN_B5,rcv=PIN_B2)
void main()
{
while (1)
{
printf("ready");
output_high(pin_b4);
delay_ms(500);
output_low(pin_b4);
delay_ms(500);
}
}
|
|
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Fri Feb 17, 2006 4:12 am |
|
|
Your program look OK to me. How did you test that no data is send by the PIC? Could it be that the problem is in the cable to your PC or something like that? I always test with a break-out box that shows data transport by blinking leds. |
|
|
Markdem
Joined: 24 Jun 2005 Posts: 206
|
|
Posted: Fri Feb 17, 2006 4:14 am |
|
|
Thanks for that ckielstra, cable is ok, i tested it with another pic. I just dont understand. Could it be just a faulty PIC?? |
|
|
Markdem
Joined: 24 Jun 2005 Posts: 206
|
|
Posted: Fri Feb 17, 2006 5:00 am |
|
|
I am going to cry. i cant belive how hard this is. i have now changed the code to use a external cyristal at 20mhz. i have put in 2 15pf caps to ground from the osc. There is no problems in running the code, eg led blinks with no problem. Now when i connect to the serial port, all i get is a bunch of break signals. my new code is below. Can anyone think of anything i can try?
Code: |
#include <16F88.h>
#FUSES NOWDT, HS, NOPUT, NOMCLR, NOBROWNOUT, NOLVP, NODEBUG, NOPROTECT, NOFCMEN, NOIESO
#use delay(clock=20000000)
#use rs232(baud=2400,parity=N,bits=8,xmit=PIN_B5,rcv=PIN_B2)
void main()
{
while (1)
{
printf("0");
output_high(pin_b4);
delay_ms(50);
output_low(pin_b4);
delay_ms(50);
}
}
|
Thank you all for your help |
|
|
Markdem
Joined: 24 Jun 2005 Posts: 206
|
|
Posted: Fri Feb 17, 2006 5:13 am |
|
|
Hi All, one more thing i have noticed, If i remove the max232 chip from the board, the pic will not start to flash!. if i just connect the pic to power, with nothing else connected, exept for the osc and led, the pic will not flash. What could be going on here??
Thanks again
Mark |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Fri Feb 17, 2006 5:45 am |
|
|
Removing the MAX232 from your circuit shouldn't have any effects on the PIC flashing the led. The fact that it does have effect makes alarm bells go off in my head. Please check the VCC and ground lines of your PIC ! It looks like the MAX232 is providing power to your PIC. |
|
|
dbotkin
Joined: 08 Sep 2003 Posts: 197 Location: Omaha NE USA
|
|
Posted: Fri Feb 17, 2006 5:05 pm |
|
|
I find it very helpful to troubleshoot this sort of thing from the hardware side first. I don't see anything obviously wrong with your code.
Pull the PIC and the MAX232 out of the circuit, you don't need them yet. First use a meter to verify voltages -- ground on the Vss pin, 5V or so on the Vdd pin. Remove power and use the Ohm meter to verify that you have a direct connection between your power supply ground and the chips, and do the same with the +5 side. Make sure all that's correct first. If you do have an oscilloscope available, by all means use it to make sure you've got DC voltage. If you don't have an o-scope, see if you can borrow one, or pick up a cheap used one. It's an invaluable tool. You can buy a cheap used 20 MHz Hitachi or something for a song on eBay, or check around at ham radio swap meets - though most of them are really going down hill.
Now put the PIC in the circuit and do some testing with a logic probe or o-scope. See if your PIC Tx pin is changing or not. If you don't have a "real" logic probe, just use an LED with a 220 or so Ohm resistor. You should see your Tx line blinking.
Once you have that working, THEN try putting the MAX232 in the circuit and see what happens.
Let us know what you find out. |
|
|
Markdem
Joined: 24 Jun 2005 Posts: 206
|
|
Posted: Fri Feb 17, 2006 7:53 pm |
|
|
Hi All, thanks for all the help. I went out and got another PIC today, and it works OK. I cant see when the other one would be doing that. It is very strange. Just must be one of those thinks.
Thanks , mark |
|
|
|
|
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
|