View previous topic :: View next topic |
Author |
Message |
kosopet
Joined: 12 Dec 2016 Posts: 2
|
pic16f1787 i2c init problem[solved] |
Posted: Mon Dec 12, 2016 4:44 am |
|
|
Hello, i am trying just to get i2c initialization on pic16f1787. I use mplab 8.92 ide and ccs v.4 c compiler. Here is my short init code:
Code: | #include <16F1787.h>
#device PIC16F1787
#use i2c(MASTER, SDA=PIN_C4, SCL=PIN_C3, FAST=1000000)
#use delay(clock=20000000)
int8 a;
void main() {
set_tris_c(0b00011000);
while(1)
{
a=3;
}
} |
than i run mplab sim debugger, and look to - Watch window in mplab, i can see only:
ssp1add = 0x00
ssp1con1 = 0x00
ssp1con2 = 0x00
ssp1con3 = 0x00
so i think that by some reason i2c initialization dont work.
Last edited by kosopet on Mon Dec 12, 2016 5:04 am; edited 1 time in total |
|
![](templates/subSilver/images/spacer.gif) |
kosopet
Joined: 12 Dec 2016 Posts: 2
|
i2c init |
Posted: Mon Dec 12, 2016 5:04 am |
|
|
just solved it was needed FORCE_HW ) |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19367
|
|
Posted: Mon Dec 12, 2016 5:48 am |
|
|
Or. use:
#use i2c(MASTER, I2C1, FAST=1000000)
This selects the hardware pins, and generates FORCE_HW as well. |
|
![](templates/subSilver/images/spacer.gif) |
|