View previous topic :: View next topic |
Author |
Message |
ertansuluagac
Joined: 13 Jul 2017 Posts: 135 Location: IZMIR
|
Communication between 2 processors |
Posted: Thu Nov 28, 2019 6:19 am |
|
|
I want to have 2 processors talk among themselves. Is serial communication a good method? or is there a method you can suggest?
Used processors:
18f45k22
18f67k40 _________________ Es |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9229 Location: Greensville,Ontario
|
|
Posted: Thu Nov 28, 2019 6:28 am |
|
|
It depends upon how much data has to be sent to them,how often and distance. Obviously parallel is faster( bytes or nibbles vs bits) but serial may be easier for you , especially for testing. You can 'sniff' the data with a PC and terminal program. Distance ? if less than 10 feet use parallel for speed.
Jay |
|
|
ertansuluagac
Joined: 13 Jul 2017 Posts: 135 Location: IZMIR
|
|
Posted: Thu Nov 28, 2019 7:00 am |
|
|
There is no distance anyway. They will be on the same card. I'm using the first processor to drive the screen. And I use the data from the second processor to press the screen.
2. The processor will send the data generated to the 1st processor. So:
1. Processor 2. Processor
RX ---------> TX
TX <------- RX
it will be. _________________ Es |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9229 Location: Greensville,Ontario
|
|
Posted: Thu Nov 28, 2019 7:08 am |
|
|
Assuming an LCD 'screen', use serial as it takes longer to display data on LCD than actual data transfers, so no benefit from using parallel methods.
Jay |
|
|
ertansuluagac
Joined: 13 Jul 2017 Posts: 135 Location: IZMIR
|
|
Posted: Thu Nov 28, 2019 11:35 am |
|
|
I think there is no need for max232 between the two processors. Or do have? _________________ Es |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19518
|
|
Posted: Thu Nov 28, 2019 11:46 am |
|
|
None whatsoever. Just direct wire. Choose a baud rate dependant on how
long the connection is. If only a few inched 500000bps for example. If
longer bring this down. Remember if you do use a fast rate you must
use interrupt driven receive. |
|
|
ertansuluagac
Joined: 13 Jul 2017 Posts: 135 Location: IZMIR
|
|
Posted: Thu Nov 28, 2019 11:58 am |
|
|
near. They will even be on the same card. 1. The processor is constantly sending data.
I'm using the second processor to drive 320x240 graphics lcd. and, I print data values from the first processor.
Code: |
Communication setting
TX(master)
#include<18F67K40.h>
#use delay(clock=64MHz,crystal=16MHz)
#pin_select U1TX = PIN_D0
#pin_select U1RX = PIN_D1
#use rs232(UART1,parity=N,bits=8,stop=1,stream=PORT1)
RX(slave)
#include<18F45K22.h>
#use delay(clock=64MHz,crystal=16MHz)
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8,stop=1,stream=PORT1)
|
_________________ Es |
|
|
alan
Joined: 12 Nov 2012 Posts: 357 Location: South Africa
|
|
Posted: Thu Nov 28, 2019 1:21 pm |
|
|
Wht not use SPI if you have spare pin. Comms are then synchronous if that are needed. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19518
|
|
Posted: Thu Nov 28, 2019 2:02 pm |
|
|
A question here is what the chips use for clocks?.
If the two chips both have crystals, or share an external master oscillator,
or both have oscillators that are guaranteed to remain within a small
percentage of one another, then really SPI has no advantage. Simple
async, is easier to code and uses less wires. Where SPI 'wins' is if the
clock cannot be guaranteed to be this close. It also does give a fractionally
higher throughput for a given baud rate (1.25*), by not requiring start
or stop bits. |
|
|
|