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

Problem with uart

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



Joined: 14 Sep 2016
Posts: 4

View user's profile Send private message

Problem with uart
PostPosted: Wed Sep 14, 2016 11:34 pm     Reply with quote

Hello everybody,
I used PIC mcu and ccs compiler.
I want to connect RXD and TXD pins together with resistor (47R) and use single wire for connecting two PIC mcu.
I copy that from one chinese board,
but UART not work well when connect together.
While disconnect work well.
Please help me it is urgent.

I need sample code for UART with single wire.
Ttelmah



Joined: 11 Mar 2010
Posts: 19488

View user's profile Send private message

PostPosted: Thu Sep 15, 2016 12:56 am     Reply with quote

It's not going to work with 47R. I think you misread the colour code on the design you are copying. I bet it was a four band code, not a three band one. Yellow purple black black 470R. Think about it. If one chip's output was high, and the other low, there would potentially be 100mA drawn if the outputs actually swung to the rails. PIC outputs are rated for 25mA _max_.....

You need to switch the UART off when each is not driving, to allow the other to drive the line. Look at the '0' parameter for 'setup_UART'. Ideally there would be a pull-up resistor on the line somewhere. It is much better done on some later PIC's that support open collector drive (FLOAT_HIGH in #use RS232).
temtronic



Joined: 01 Jul 2010
Posts: 9220
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Thu Sep 15, 2016 4:51 am     Reply with quote

CCS supplies both schematic and software for 'single wire UART' ! I think it's still in the 'Common Questions and Answers' section of the manual. It was there there 20 years ago.

Edit. yes, it's STILL there ! See 'What is an easy way to connect2 or more PICs'. They show all B0 pins tied togther with a common 1K pullup. Your board may be using a 470r instead.

Jay
tarasheh110



Joined: 14 Sep 2016
Posts: 4

View user's profile Send private message

PostPosted: Thu Sep 15, 2016 6:13 am     Reply with quote

thanks alot.
I check again resistor.
It 's 47 ohm.


RXD---------/\/\/\/\/------------------------->single wire
***********47R********|
********************** |
TXD---------/\/\/\/\/\------------------------->single wire
********** 47R
Ttelmah



Joined: 11 Mar 2010
Posts: 19488

View user's profile Send private message

PostPosted: Thu Sep 15, 2016 6:44 am     Reply with quote

The only way it is going to work with 47R, is by disabling the UART's when they are not used, so the resistor actually does nothing. It then only comes into play if both UART's are turned on at the same time, when it still risks damaging the PIC's....

It could just be an attempt to reduce reflection. If so the code would have to be working 'polled'. So the UART's are both disabled, and the 'master' PIC initiates all communications. Enabling it's UART, and sending any output data, and a 'request' for reply. Then the 'slave' PIC only enables it's UART when this is seen and replies. The resistors then do nothing, except if the data rate is high, try to reduce signal reflection on the wire.
tarasheh110



Joined: 14 Sep 2016
Posts: 4

View user's profile Send private message

PostPosted: Fri Sep 16, 2016 11:17 am     Reply with quote

How I can turn off rxd pin when txd is on?
temtronic



Joined: 01 Jul 2010
Posts: 9220
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Fri Sep 16, 2016 12:51 pm     Reply with quote

Make your life EASY... look at , compile, run....
the two examples that CCS kindly supply, in the 'examples' folder. The program names are in the Common Questions and Answers, 'how to connect 2 or more PICS on a single wire.


Jay
tarasheh110



Joined: 14 Sep 2016
Posts: 4

View user's profile Send private message

PostPosted: Sat Sep 17, 2016 1:58 am     Reply with quote



Please have look to images. Waveforms are different Exclamation Exclamation Exclamation
Please help me
temtronic



Joined: 01 Jul 2010
Posts: 9220
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sat Sep 17, 2016 5:13 am     Reply with quote

Very interesting ! I'm going to say extra capacitance on the pin. This increases the time it takes to 'charge' and 'discharge' and shows as a 'rounding' effect when seen on a scope. It could also be large R though high value of C has my vote without seeing it 'on the bench'.
hmmm.
This _might_ also be caused by NOT using 'fast_io()' to setup the I/O pins of the PIC . Again without seeing it in front of me it's hard say exactly but youve got 2 things to looks at!

When it's fixed, please post WHAT was the cuase as others should be told.

Jay
ccs.user2k15



Joined: 24 Jun 2015
Posts: 1

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

I can reverse engineer it
PostPosted: Mon Sep 19, 2016 5:33 am     Reply with quote

Hi

I can reverse engineer the device and write exact code using CCS PICC.
_________________
Regards

ccs.user2k15
Ttelmah



Joined: 11 Mar 2010
Posts: 19488

View user's profile Send private message

PostPosted: Thu Sep 22, 2016 3:12 am     Reply with quote

The different waveform though is not a code issue.

Hardware somewhere. Different chip?. Different wires?. etc. etc..

Once data is being actually 'sent', the edge shapes are determined by the drive capabilities of the pins, and the impedances/capacitances in the circuit.

There is no control on the rising and falling edge 'rates' on pins, (except for a few very specialised ones like I2C pins on some of the newer PIC's, and a few with adjustable current limits). However in general newer PIC's often have much lower drive currents on the equivalent pins than older models....
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