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 support@ccsinfo.com

Rs232 part II

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







Rs232 part II
PostPosted: Mon Nov 04, 2002 10:07 am     Reply with quote

<font face="Courier New" size=-1>hi again,

here is program I am trying with 16f876 to work on RS232,

#include <16F876.h>
#id CHECKSUM
#device *=16
#use delay(clock=8000000,RESTART_WDT)
#fuses HS,WDT,NOBROWNOUT,NOPUT
#use rs232(baud=19200,parity=N,xmit=PIN_C6,rcv=PIN_C7,BITS=8,BRGH1OK)
#zero_ram
#int_RDA

RDA_isr() {
output_low(PIN_B5);
delay_ms(500);
output_high(PIN_B5);
}

void main() {

setup_counters(RTCC_INTERNAL,WDT_2304MS);
setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_CLOCK_DIV_2);
setup_spi(FALSE);
setup_counters(RTCC_INTERNAL,RTCC_DIV_2);
setup_timer_1(T1_INTERNAL|T1_DIV_BY_1);
setup_timer_2(T2_DISABLED,0,1);
setup_ccp1(CCP_OFF);
setup_ccp2(CCP_OFF);

output_high(PIN_B5);

while (TRUE)
PRINTF("hello word");


}

when I use monitor to recive from pic I get all time:

2F 35 27 27 21 BF 11 21 1B 37 2F 35 27 27 21 BF (hex)
"! 7/5īī!/5īī!" ASCII

I checked hardware is ok and terminal program is configured ok,
but no way to go arround this problem,
pcw version is 3.082 so I assume I am doing something wrong,

best regards
Invisible</font>
___________________________
This message was ported from CCS's old forum
Original Post ID: 8485
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

Re: Rs232 part II
PostPosted: Mon Nov 04, 2002 11:14 am     Reply with quote

Are you using an RS232 transceiver chip like the MAX232?

Mark

:=<font face="Courier New" size=-1>hi again,
:=
:=here is program I am trying with 16f876 to work on RS232,
:=
:=#include <16F876.h>
:=#id CHECKSUM
:=#device *=16
:=#use delay(clock=8000000,RESTART_WDT)
:=#fuses HS,WDT,NOBROWNOUT,NOPUT
:=#use rs232(baud=19200,parity=N,xmit=PIN_C6,rcv=PIN_C7,BITS=8,BRGH1OK)
:=#zero_ram
:=#int_RDA
:=
:=RDA_isr() {
:= output_low(PIN_B5);
:= delay_ms(500);
:= output_high(PIN_B5);
:=}
:=
:=void main() {
:=
:= setup_counters(RTCC_INTERNAL,WDT_2304MS);
:= setup_adc_ports(NO_ANALOGS);
:= setup_adc(ADC_CLOCK_DIV_2);
:= setup_spi(FALSE);
:= setup_counters(RTCC_INTERNAL,RTCC_DIV_2);
:= setup_timer_1(T1_INTERNAL|T1_DIV_BY_1);
:= setup_timer_2(T2_DISABLED,0,1);
:= setup_ccp1(CCP_OFF);
:= setup_ccp2(CCP_OFF);
:=
:= output_high(PIN_B5);
:=
:= while (TRUE)
:= PRINTF("hello word");
:=
:=
:=}
:=
:=when I use monitor to recive from pic I get all time:
:=
:=2F 35 27 27 21 BF 11 21 1B 37 2F 35 27 27 21 BF (hex)
:="! 7/5īī!/5īī!" ASCII
:=
:=I checked hardware is ok and terminal program is configured ok,
:=but no way to go arround this problem,
:=pcw version is 3.082 so I assume I am doing something wrong,
:=
:=best regards
:=Invisible</font>
___________________________
This message was ported from CCS's old forum
Original Post ID: 8487
Invisible
Guest







Re: Rs232 part II
PostPosted: Mon Nov 04, 2002 12:10 pm     Reply with quote

hi,

no, since 16f876 have built in sci I think I donīt need it,
chip is conected as follow:

PIC PC
--- --
Tx Rx
Rx Tx
Gnd Gnd

best regards
Invisible

:=Are you using an RS232 transceiver chip like the MAX232?
:=
:=Mark
:=
___________________________
This message was ported from CCS's old forum
Original Post ID: 8497
Sherpa Doug
Guest







Re: Rs232 part II
PostPosted: Mon Nov 04, 2002 12:30 pm     Reply with quote

:=hi,
:=
:=no, since 16f876 have built in sci I think I donīt need it,
:=chip is conected as follow:
:=
:=PIC PC
:=--- --
:=Tx Rx
:=Rx Tx
:=Gnd Gnd
:=
:=best regards

A standard PC RS232 port operates at +/-12V. Your PIC is probably running at near +5v. You need something like a MAX232 chip to do the voltage conversion. Such converter chips usually do a logic inversion too. Odds are your logic is inverted and running 12V directly into a 5V PIC is not healthy for the PIC.

___________________________
This message was ported from CCS's old forum
Original Post ID: 8500
Invisible
Guest







Re: Rs232 part II
PostPosted: Mon Nov 04, 2002 12:51 pm     Reply with quote

hi,

but I thought that 16f87x had hardware sci and didnīt need max232, thatīs right? or does I need allways a max232?,

best regards
Invisible

:=
:=A standard PC RS232 port operates at +/-12V. Your PIC is probably running at near +5v. You need something like a MAX232 chip to do the voltage conversion. Such converter chips usually do a logic inversion too. Odds are your logic is inverted and running 12V directly into a 5V PIC is not healthy for the PIC.
:=
___________________________
This message was ported from CCS's old forum
Original Post ID: 8501
johnpcunningham
Guest







Re: Rs232 part II
PostPosted: Mon Nov 04, 2002 1:33 pm     Reply with quote

<font face="Courier New" size=-1>Sherpa is right.

If you are going to communicate to a PC, you must have an RS232 inverter in there. Your PIC does have an SCI (i.e. RS232, UART are other names for it) but it does not have the RS232 line driver built in. The purpose for the line-driver (i.e. MAX232) is to increase the voltage and invert the logic (better noise immunity and drive current). Your PC also has a line driver that increases the voltage and inverts the logic as well

When you transfer the data to your PC from the PIC, the MAX232 inverts the logic. When it get to the PC from the serial cable, it goes into the MAX232 equivelent on the motherboard and the the logic gets inverted back to what it was originally.

Here is a website to get the data sheets for the MAX232 chip.

<a href="http://www.maxim-ic.com/quick_view2.cfm/qv_pk/1798" TARGET="_blank"> <a href="http://www.maxim-ic.com/quick_view2.cfm/qv_pk/1798" TARGET="_blank">http://www.maxim-ic.com/quick_view2.cfm/qv_pk/1798</a></a>

You can probably get this chip online from digikey.com or some other electronics store or distributor
</font>
___________________________
This message was ported from CCS's old forum
Original Post ID: 8505
Sherpa Doug
Guest







Re: Rs232 part II
PostPosted: Mon Nov 04, 2002 3:50 pm     Reply with quote

:=but I thought that 16f87x had hardware sci and didnīt need max232, thatīs right? or does I need allways a max232?,
:=
:=best regards
:=Invisible

The sci (or uart or whatever it is called) takes care of timing and parallel to serial conversion. It does nothing about voltage level shifting.

___________________________
This message was ported from CCS's old forum
Original Post ID: 8516
R.J.Hamlett
Guest







Re: Rs232 part II
PostPosted: Mon Nov 04, 2002 3:55 pm     Reply with quote

:=hi,
:=
:=but I thought that 16f87x had hardware sci and didnīt need max232, thatīs right? or does I need allways a max232?,
:=
You need a MAX232, or equivalent. The chip contains a built in UART (does serial to parallel, and parallel to serial conversions), but no line interface. The actual interface to use will depend on what you are driving (many people here will be using other interface standards like differential RS485, rather than RS232).
Fortunately though RS232, is normally at a higher voltage, the source impedance is relatively high, and the clamp diodes on the chip, should have prevented damage, but the signals themselves are also inverted, which is why it won't work.

:=best regards
:=Invisible

Best Wishes


:=:=
:=:=A standard PC RS232 port operates at +/-12V. Your PIC is probably running at near +5v. You need something like a MAX232 chip to do the voltage conversion. Such converter chips usually do a logic inversion too. Odds are your logic is inverted and running 12V directly into a 5V PIC is not healthy for the PIC.
:=:=
___________________________
This message was ported from CCS's old forum
Original Post ID: 8517
Dave Yeatman
Guest







Re: Rs232 part II
PostPosted: Mon Nov 04, 2002 4:08 pm     Reply with quote

:=hi,
:=
:=but I thought that 16f87x had hardware sci and didnīt need max232, thatīs right? or does I need allways a max232?,
:=
:=best regards
:=Invisible
:=
:=:=
:=:=A standard PC RS232 port operates at +/-12V. Your PIC is probably running at near +5v. You need something like a MAX232 chip to do the voltage conversion. Such converter chips usually do a logic inversion too. Odds are your logic is inverted and running 12V directly into a 5V PIC is not healthy for the PIC.
:=:=

Invisible,
One other option that I have used on occasion (and I use for a quick test on my R&D bench) is to simply use a SN7404 inverter (or 7408 with the inputs tied together) to invert the signal from the PIC to the PC. This is quick and cheap but it DOES NOT give you the noise immunity so you have to keep the run to the PC to a short distance for it to work semi-reliably. You can get one of these at virtually any electronics shop including Radio Shack.

Dave
___________________________
This message was ported from CCS's old forum
Original Post ID: 8519
Invisible
Guest







thank you very much to all!!!!!!!!!
PostPosted: Tue Nov 05, 2002 3:50 am     Reply with quote

hi,

now I clear up my mind, I was bypassing the max232 so no strange that I got that strange things.
Next time I will read carefully the pic datasheet, thanks also to Dave for the idea of 7404, I have here 74174 so I will fix it,
thanks to everyone,

best regards
Invisible
___________________________
This message was ported from CCS's old forum
Original Post ID: 8538
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