View previous topic :: View next topic |
Author |
Message |
randy.shaffer
Joined: 21 Mar 2018 Posts: 51
|
PIC-to-PIC RS232 problem |
Posted: Fri Apr 22, 2022 11:09 am |
|
|
The first is an 18F55K42, the second 18LF55K42. The second sends and receives data OK, the first sends OK but does not receive (kbhit never is true in the first).
Settings for the first:
Code: | #include <18F55K42.h>
#include <stdint.h>
#device ADC = 10
#fuses NOWDT, BROWNOUT, PUT_64MS, NOLVP
#use delay(internal=64MHz)
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8,disable_ints,stream=VOICE_COUNTDOWN)
|
Settings for the second:
Code: | #include <18LF55K42.h>
#include <stdint.h>
#fuses NOWDT, PUT_64MS
#use delay(internal = 64MHz)
#pin_select NULL = PIN_C3 // disconnect i2c module from C3, C4
#pin_select NULL = PIN_C4
#pin_select U1TX = PIN_C7 // Connections are TX-TX, RX-RX on PCB
#pin_select U1RX = PIN_C6
#use rs232(UART1,baud=9600,parity=N,bits=8,disable_ints,stream=MAIN_BOARD) |
The section in the first to receive is in a continuous loop:
Code: | if(kbhit(VOICE_COUNTDOWN) == TRUE)
{
RX_DATA = fgetc(VOICE_COUNTDOWN);
}
|
RX_DATA is uint8_t
Compiler is 5.107
This is my first attempt to get two pics to communicate, I apologize in advance for the ignorance/inexperience. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19504
|
|
Posted: Fri Apr 22, 2022 11:15 am |
|
|
Are you wiring these directly to one another without buffers?. If so,
voltage is the problem. The F will be drivng to 5v, the LF only 3.3. If the
connection is directly made, then the input to the LF will be being
overdriven (if this not a 5v tolerant pin, then this could damage the
chips). The F will not see a high enough voltage to work. The ViH at
5v, is 4v. |
|
|
randy.shaffer
Joined: 21 Mar 2018 Posts: 51
|
|
Posted: Fri Apr 22, 2022 11:19 am |
|
|
Yes, wired directly w/o buffers, both are operating at 5v. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9225 Location: Greensville,Ontario
|
|
Posted: Fri Apr 22, 2022 2:41 pm |
|
|
hmm, proper RS-232 buffers will invert the data... so I suspect if you add 'invert' to the USE RS232 (..options...), it may 'magically' work for you, providing both PICs are 5v. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19504
|
|
Posted: Sat Apr 23, 2022 2:48 am |
|
|
The LF chip is rated for 3.6v _MAX_
You will almost certainly have damaged it if you are running at 5v.
He doesn't need 'invert', since the signals will both be idle +ve on both
chips. Remember Jay, you use two RS232 buffers, so the signals are
inverted twice over an RS232 connection.
His operating voltage is illegal for the pair of chips he is using. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9225 Location: Greensville,Ontario
|
|
Posted: Sat Apr 23, 2022 4:03 am |
|
|
yeah, getting old sucks,.. I was membering connecting to a PIC to PC.and the 'cheat' was to not have the MAX232 BUT had to use the 'invert' option. This was back when PICs had quartz windows on top so you could se 'under the hood'...... |
|
|
randy.shaffer
Joined: 21 Mar 2018 Posts: 51
|
|
Posted: Mon Apr 25, 2022 9:10 am |
|
|
Thank you, sirs, for your help. I have indeed selected the wrong chip and am headed back to the drawing board. |
|
|
|