View previous topic :: View next topic |
Author |
Message |
sanshiroo
Joined: 20 Apr 2014 Posts: 4
|
why my I2C register don't change |
Posted: Mon Apr 21, 2014 7:29 pm |
|
|
Now I use function i2c, but when I debug program for check register value the register SSPCON SSPCON2 SSPSTAT value is 0x00 don't change value.
Why the register don't change value?
This is my code
Code: |
#include <16F886.h>
#use I2C(master,sda=pin_c4,scl=pin_c3)
void main()
{
i2c_start();
i2c_write(0xD0);
i2c_write(0xff);
i2c_stop();
}
|
thank a lot |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Apr 21, 2014 8:20 pm |
|
|
Quote: | #use I2C(master,sda=pin_c4,scl=pin_c3)
SSPCON SSPCON2 SSPSTAT value is 0x00 don't change value.
|
Download the CCS manual and read the #use i2c() section:
https://www.ccsinfo.com/downloads/ccs_c_manual.pdf
It says:
Quote: | Software functions are generated unless FORCE_HW is specified. |
|
|
|
sanshiroo
Joined: 20 Apr 2014 Posts: 4
|
|
Posted: Mon Apr 21, 2014 8:59 pm |
|
|
PCM programmer wrote: | Quote: | #use I2C(master,sda=pin_c4,scl=pin_c3)
SSPCON SSPCON2 SSPSTAT value is 0x00 don't change value.
|
Download the CCS manual and read the #use i2c() section:
https://www.ccsinfo.com/downloads/ccs_c_manual.pdf
It says:
Quote: | Software functions are generated unless FORCE_HW is specified. |
|
thank a lot
And what is the difference of use FORCE_HW and don't use |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19480
|
|
Posted: Tue Apr 22, 2014 12:28 am |
|
|
Because it doesn't use the hardware (so no registers changing...).
It generates extra code, to produce a software I2C emulation driver. Slower, bulkier, can only do 'master', but has the advantage it can be used on any pins, and on the PIC's that don't have hardware - hence the reason this is the default. |
|
|
|