View previous topic :: View next topic |
Author |
Message |
free_will
Joined: 09 Nov 2006 Posts: 2
|
Sharing Hardware resource for UART and I2C at runtime |
Posted: Thu Nov 09, 2006 7:22 am |
|
|
Hi,
I am using PIC16F917 and only got one hardware resource for communication.
How can I select/change hardware resource for I2C or UART in runtime ?
I want to use hardware resource as I2C most time , but I need to also use UART hardware for a short period.Ofcourse they wont be working at the same time...The reason why I am not using software UART is ; I can not go higher baud rates upper than 9600bps with 8MHz internal clock...
I beleive selecting hardware for I2C or UART wont be a problem by investigating related registers , but I am seeking a way if compiler can do that.
Thanks! |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Nov 09, 2006 12:38 pm |
|
|
There are bits in the control registers for the UART and i2c (SSP)
modules that can enable/disable the modules. You would have to set
the proper TRIS settings for the current module that's using the pins.
You would also need external circuits to disable the MAX232-type chip
or the i2c chip, as required, so the chip that is not being used doesn't
interfere with the one that is in use. (Some MAX232-type chips can
be bought which have an Enable pin on the chip).
It's easier just to move the i2c signals to some other free pins and
use software i2c. That's my recommendation. |
|
|
free_will
Joined: 09 Nov 2006 Posts: 2
|
|
Posted: Thu Nov 09, 2006 1:35 pm |
|
|
Hi,
That's exacly what I am workin on now , software I2C. After thinking deeply ,it is obvious that I2C Software will have very less load on CPU if compared with software UARTand the advantage is Master creating its own clock , so no possibility to miss any data provided that interrupts are disabled...
About sharing resources , I see that it is a complicated procedure, considering interference , I can not see any disadvanatge using software I2C.
You have been very helpful.
Thank you! |
|
|
|