View previous topic :: View next topic |
Author |
Message |
tarasheh110
Joined: 14 Sep 2016 Posts: 4
|
Problem with uart |
Posted: Wed Sep 14, 2016 11:34 pm |
|
|
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
|
|
Posted: Thu Sep 15, 2016 12:56 am |
|
|
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
|
|
Posted: Thu Sep 15, 2016 4:51 am |
|
|
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
|
|
Posted: Thu Sep 15, 2016 6:13 am |
|
|
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
|
|
Posted: Thu Sep 15, 2016 6:44 am |
|
|
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
|
|
Posted: Fri Sep 16, 2016 11:17 am |
|
|
How I can turn off rxd pin when txd is on? |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9220 Location: Greensville,Ontario
|
|
Posted: Fri Sep 16, 2016 12:51 pm |
|
|
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
|
|
Posted: Sat Sep 17, 2016 1:58 am |
|
|
Please have look to images. Waveforms are different
Please help me |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9220 Location: Greensville,Ontario
|
|
Posted: Sat Sep 17, 2016 5:13 am |
|
|
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
|
I can reverse engineer it |
Posted: Mon Sep 19, 2016 5:33 am |
|
|
Hi
I can reverse engineer the device and write exact code using CCS PICC. _________________ Regards
ccs.user2k15 |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19488
|
|
Posted: Thu Sep 22, 2016 3:12 am |
|
|
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.... |
|
|
|