![]() |
![]() |
![]() |
|
|
|||||||
| Electronic Projects Design/Ideas/Reviews Are you building an electronic project or want to? Maybe you need some assistance? Come and submit your electronic questions here and let our experienced members find a solution. |
|
|
Thread Tools | Display Modes |
|
|
(permalink) |
|
I am developing some sort of multi controller device. It has two PIC microcontrollers (PIC18F4550 and PIC18F4680) can i use the USART for communication between the chips i.e. Can I just connect the RX of one chip to the TX of the other chip to do this? And can I use the serial data receive interrupt to read the data? At what maximum baud rate can i transfer the data? (The two microcontrollers just few centimeters apart as they are on the same board)
|
|
|
|
|
|
|
(permalink) |
|
Yes, Yes, and consult the datasheet. You do have the respective datasheets: don't you?
__________________
We never have time to do it right; but we always have time to do it over. |
|
|
|
|
|
|
(permalink) |
|
ya i have the datasheets. Actually it runs fine in the simulation but i asked the question because i wanted to be sure.
|
|
|
|
|
|
|
(permalink) |
|
In short? yes! You might want to add series resistors to both the lines (Tx->Rx, and Rx-> Tx) just incase something goes wrong. Something like 1-10k sohuld be fine.
You can of course use the data recieve interupt to 'read' the data. In fact, its probably the best way of doing it rather than polling the 'data recieved' flag. The maximum baud depends on the oscillators in the PIC's. If they are only a few centimeters apart, I woudn't have thought you'd get much in the way of noise/signal degredation. Look at the datasheets and find the 'maximum' baud rate for the crystal osc's you're using. It'll probably be up in the MB/s range. If you wish to go even faster, PIC's USARTs have a sync mode, whereby a master produces a clock to go with the data, much more stable at high datarates, and can approach 2.5MB/s. Although as I said, one has to be a master and one has to be a slave (only the master provides the clock). For async mode (normal USART operation) I would pick a baud that is perfectly accurate with your clocks. No point in configuring it for 19200 if you're oscillator would give the baud rate generator a % error. Check out the datasheet for the PICs and the BRG. Alternatively you can use the SPI (MSSP) module to transfer bytes between the micro's at very high speed. If the PIC's are on the same board, and a few CM apart, then a good 5Mhz wouldn't be too tricky. Again with SPI, one has to be the master and one the slave, so only one provides the clock. On a side note SPI is a data exchange protocol...that is...when the master sends a byte to the slave, at the same time data is 'taken' from the slave. Blueteeth
__________________
Inconsistency is the key to flexibility! |
|
|
|
|
|
|
(permalink) |
|
lol, bloody typical, I go off on one...and papabravo just does the short version
__________________
Inconsistency is the key to flexibility! |
|
|
|
|
|
|
(permalink) |
|
Thanks Blueteeth.
|
|
|
|
|
|
|
(permalink) |
|
Take a look at Application Note AN774 on the Microchip website.
It has working code examples of 4 or 5 communications usart methods, including the Interrupt driven Tx / Rx and polled / wait examples that can be downloaded in the .zip file and 'run' with little or no changes, it looks like it may be exactly what you want. The App note covers the PIC16 / PIC17 and the PIC18 family as well. |
|
|
|
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Latest |
| Drive 33 Servos With One PIC + USART | wschroeder | Micro Controllers | 40 | 14th July 2008 02:22 PM |
| usart with pic | neelam29 | Micro Controllers | 11 | 9th April 2008 01:09 PM |
| serial communication with pic 18f4550 | neelam29 | Micro Controllers | 4 | 2nd March 2008 05:53 PM |
| RF receive using PIC USART | col_implant | Electronic Projects Design/Ideas/Reviews | 11 | 15th November 2007 04:05 PM |
| serial communication from PIC to PC | flemmard | Electronic Projects Design/Ideas/Reviews | 10 | 11th September 2007 11:07 AM |