|
|
View previous topic :: View next topic |
Author |
Message |
Theodorus
Joined: 21 Aug 2017 Posts: 2
|
How to unselect I2C-Module the CCS way??? |
Posted: Mon Aug 21, 2017 9:59 am |
|
|
The code
#use i2c(MASTER, I2C1, FAST, FORCE_HW, STREAM= Motor)
connects the port pins to the i2c- module.
For diagnostic purposes the sda and scl pins of the bus should be analyzed if a i2c bus lookup event occurred. To get free access to these port pins,
the i2c- module is switched of "by hand" by disabling the i2c- module while
setting I2CEN(bit15) of the I2CxCON (i2c control register) to zero and switch back to i2c- module after checking with #use i2c(MASTER,.........).
Is there a more elegant way to unselect the hardware i2c- module in CCS- C during runtime?
device= PIC24FJ256GB210 |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19520
|
|
Posted: Mon Aug 21, 2017 11:20 am |
|
|
This is where the NOINIT option comes in.
Most of the peripherals on modern compilers can be setup using this option.
So:
Code: |
#use i2c(MASTER, I2C1, FAST, FORCE_HW, STREAM= Motor, NOINIT)
|
Then when you want to use it, have:
i2c_init(Motor, TRUE);
Then to disable:
i2c_init(Motor, FALSE);
Similar commands exist for the serial, SPI etc..
Worth saying that using the peripheral name (I2C1), automatically implies FORCE_HW already. |
|
|
Theodorus
Joined: 21 Aug 2017 Posts: 2
|
|
Posted: Mon Aug 21, 2017 11:53 am |
|
|
Thanks Ttelmah for pointing me in the right direction, that's the solution I was looking for. You made my day. |
|
|
|
|
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
|