CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

RS232,16F870 problem

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
John
Guest







RS232,16F870 problem
PostPosted: Mon Feb 03, 2003 7:22 am     Reply with quote

Hello!
I'm having a hard time getting the RS232 PIC/PC communication to work. PIC->PC is ok, but the PIC doesn't seem to read anything on RX even though the signal is there. Checked everything with a scope. I use a MAX232. Tried both hardware UART and software (xmit=b3, rcv=b2) but the same things happen. Tried 4/20Mhz osc with a number of different baudrates but no, it doesn't seem to read RX. Also tried removing fast_io, tris statements, adding PARITY etc but no. Now I'm running out of ideas...

This is the testprogram I've been wrestling with:

#include <16f870m.h>
#fuses HS, NOPROTECT, NOWDT, PUT, NOBROWNOUT, NOLVP
#use DELAY(clock=4000000)
#use fast_io ( A )
#use fast_io ( B )
#use fast_io ( C )
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)

void main( void )
{
char Com;

set_tris_a ( 0b00000000 );
set_tris_b ( 0b00000000 );
set_tris_c ( 0b10000000 ); // RC7 input

printf("\n\r Testing...");

while(1)
{
putc(getc()+1);
}
}

I get the "Testing"-part but then it stops. It doesn't echo back. I used an F84 earlier and it started to "work" when I changed from Hyperterminal to TeraTerm.

Since I have an old PCM v.2.686 which doesn't support the F870 I use the 16F873 headerfile (but use F870 in MPLab). Can this be the reason? But comparing the specs and headerfiles it looks like it should work anyway. Everything else I've tried so far has worked, why not this? Any ideas?

Sincerely,
John
___________________________
This message was ported from CCS's old forum
Original Post ID: 11229
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

Re: RS232,16F870 problem
PostPosted: Mon Feb 03, 2003 1:23 pm     Reply with quote

:=Hello!
:=I'm having a hard time getting the RS232 PIC/PC communication to work. PIC->PC is ok, but the PIC doesn't seem to read anything on RX even though the signal is there. Checked everything with a scope. I use a MAX232. Tried both hardware UART and software (xmit=b3, rcv=b2) but the same things happen. Tried 4/20Mhz osc with a number of different baudrates but no, it doesn't seem to read RX. Also tried removing fast_io, tris statements, adding PARITY etc but no. Now I'm running out of ideas...
----------------------------------------------------------

I compiled your program with PCM vs. 2.686, for a 16F877.
I tested it on 16F877 chip and it worked fine.
(I don't have a 16F870).

I then compiled it with PCM vs. 3.136 and briefly compared
the .LST files. I noticed that the older compiler uses the
TRIS instruction, which is supposedly obsolete. This might
be the answer. So let's check that first.

In your program, add the following lines above main():

#byte TRIS_A_REG = 0x85
#byte TRIS_B_REG = 0x86
#byte TRIS_C_REG = 0x87

Then, within main(), comment out your existing tris
statements, and add these lines. Like this:

//set_tris_a ( 0b00000000 );
//set_tris_b ( 0b00000000 );
//set_tris_c ( 0b10000000 );

TRIS_A_REG = 0b00000000;
TRIS_B_REG = 0b00000000;
TRIS_C_REG = 0b10000000;

See if that fixes the problem.
___________________________
This message was ported from CCS's old forum
Original Post ID: 11238
John
Guest







Re: RS232,16F870 problem
PostPosted: Mon Feb 03, 2003 4:15 pm     Reply with quote

:=I compiled your program with PCM vs. 2.686, for a 16F877.
:=I tested it on 16F877 chip and it worked fine.
:=(I don't have a 16F870).
:=
:=I then compiled it with PCM vs. 3.136 and briefly compared
:=the .LST files. I noticed that the older compiler uses the
:=TRIS instruction, which is supposedly obsolete. This might
:=be the answer. So let's check that first.
:=
:=In your program, add the following lines above main():
:=
:=#byte TRIS_A_REG = 0x85
:=#byte TRIS_B_REG = 0x86
:=#byte TRIS_C_REG = 0x87
:=
:=Then, within main(), comment out your existing tris
:=statements, and add these lines. Like this:
:=
:=//set_tris_a ( 0b00000000 );
:=//set_tris_b ( 0b00000000 );
:=//set_tris_c ( 0b10000000 );
:=
:=TRIS_A_REG = 0b00000000;
:=TRIS_B_REG = 0b00000000;
:=TRIS_C_REG = 0b10000000;
:=
:=See if that fixes the problem.
:=

Thanks for your suggestion. Tried it, but it didn't make any difference. I checked to see if it responded to any sort of input [if(input(pin_b1)) output_high(pin_c4)] etc. and that seemed fine. I am very lost here...
/John
___________________________
This message was ported from CCS's old forum
Original Post ID: 11246
John
Guest







I am an idiot...
PostPosted: Mon Feb 03, 2003 4:46 pm     Reply with quote

There are really no excuses but evidently my wife sent some e-mails having my 5 month old son in her lap. At some unattended second he happened to pick out the MAX232 grounding... Why not the supply? That one is bright red?? Why not all wires since he really can't pick anything with any sort of accuracy... Don't know whether I should laugh or cry...

So, I'm really sorry for causing unnecessary work.

/John (maybe I should change my nick?)
___________________________
This message was ported from CCS's old forum
Original Post ID: 11248
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

Re: I am an idiot...
PostPosted: Mon Feb 03, 2003 5:02 pm     Reply with quote

<font face="Courier New" size=-1>:=There are really no excuses but evidently my wife sent some e-mails having my 5 month old son in her lap. At some unattended second he happened to pick out the MAX232 grounding... Why not the supply? That one is bright red?? Why not all wires since he really can't pick anything with any sort of accuracy... Don't know whether I should laugh or cry...
:=
:=So, I'm really sorry for causing unnecessary work.
:=
:=/John (maybe I should change my nick?)
------------------------------------------------

I was about to post (in 30 seconds), that there must
be a hardware problem. :)

One more thing I forgot to mention -- In your #fuses statement
you're using HS, but your crystal is only 4 MHz. The data
sheet recommends using XT mode for that frequency.
</font>
___________________________
This message was ported from CCS's old forum
Original Post ID: 11249
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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