how to use RS485 communication and SPI expander

For C and ASSEMBLY users to post questions and code snippets for programming in C and ASSEMBLY. And for any other C or ASM course related questions.

Moderators: Benj, Mods

Post Reply
saravana_3
Posts: 61
Joined: Thu Dec 20, 2007 4:23 pm
Location: singapore
Contact:

how to use RS485 communication and SPI expander

Post by saravana_3 »

hi friends,
I am using the pic16f877a for the RS 485 master slave communication as per the data sheet the SPI or the I2C are the serial communication with the peripherals as a master slave logic, but currently i am using the master slave communication between two pic 16f877a chips, since I need additional I/O ports for my project I am insist to use the expanders MCP23S17, . but I need to connect the master and slave through the PORTC, for RS 485 communication, but the SPI and I2C caonfiguration also in the PORTC , in this case how to manage the RS 485 communication and SPI for the expander at the same time is it possible to use at the same time
thanks
Saran
saran

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: how to use RS485 communication and SPI expander

Post by Benj »

Hello Saran

It depends which chip you are using. Some of the PIC micro devices share the SPI and UART on the same pins. If this is the case for your chip then you will not be able to implement the RS485 and the SPI without bit banging one of the busses.

Sean
Valued Contributor
Valued Contributor
Posts: 548
Joined: Tue Jun 26, 2007 11:23 am
Has thanked: 6 times
Been thanked: 44 times
Contact:

Re: how to use RS485 communication and SPI expander

Post by Sean »

In the PIC16F877a the USART and MSSP (SPI/I2C) are both on Port C, but use different pins, so can operate simultaneously. You only need to route each port pin to the appropriate external device.

You will need to decide between SPI or I2C for the port expander device because these use the same controller and port pins.

Note: The USART and MSSP can not be used simultaneously on all 40-pin PIC devices

jadiflow
Flowcode v5 User
Posts: 273
Joined: Thu Apr 17, 2008 9:59 am
Has thanked: 19 times
Been thanked: 16 times
Contact:

Re: how to use RS485 communication and SPI expander

Post by jadiflow »

Saran, or anybody else, have you been successfull in using an RS485 interface?

Jan Didden

Post Reply