|
|
View previous topic :: View next topic |
Author |
Message |
evan
Joined: 02 Apr 2012 Posts: 22
|
reusing #use (spi and i2c) - help! |
Posted: Fri Aug 29, 2014 11:22 am |
|
|
Hi all,
I've got a tricky problem. My hardware is constrained by lack of pins, so I combined i2c and spi peripheral devices, sharing clock and data lines (using the software driver libraries).
Electrically it works fine and I am able to configure the i2c devices first, then the #use SPI call, then the SPI device is accessed. All OK.
However, now I need my program to access one of the i2c devices occasionally, after the #spi call.
But apparently the #use i2c call can't be done more than once. I get
Code: | Option invalid Bad Option: 116 |
How can I get the libraries to share? I realise this is a little non-standard but I know the library code is there and it does work perfectly.
Is the only way to code my own SPI routine? That would be a pain!
Thanks
Evan |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19498
|
|
Posted: Fri Aug 29, 2014 1:14 pm |
|
|
Key to understand, is that #use, is a preprocessor directive, not code.
Setup the two #use statements, with different stream names, and use these with the i2c/spi functions.
However I'm very surprised you can mix the buses. Given that I2C, is an 'open collector' bus, while SPI requires hardware pull up/down.
Tell the two statements to both force software mode, and then manually float/drive the pins involved, before switching. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|