|
|
View previous topic :: View next topic |
Author |
Message |
PA_papa_wolf
Joined: 11 Nov 2019 Posts: 9
|
I cannot use I2C.(16F18854) |
Posted: Sun Oct 25, 2020 12:45 am |
|
|
I want to use I2C (both master/slaves) in PIC.
An error was given at slave I2C when I wrote a code.
”Error#99 Option invalid Wrong pins for H/W”
Code: |
#include <16F18854.h>
#include <string.h> //strcmp()
#Fuses RSTOSC_LFINTRC,NOCLKOUT,NOBROWNOUT,NOMCLR,CPD // code protect
#use delay(internal=4000000)
#use rs232(baud=9600, xmit=PIN_A0, rcv=PIN_E3, stream=UPPER)
#use I2C(master, sda=PIN_A2, scl=PIN_A1) //master I2C software
#use I2C(slave, sda=PIN_C4, scl=PIN_C3, address=0xa0) //slave I2C HW
void main() {
}
|
I think that I do not get a wrong pin designation, is it misunderstanding?
Or is it a mistake of the setting? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Oct 25, 2020 1:04 am |
|
|
Modern PICs often require #pin_select. See the "Sticky" post at the top
of the forum.
Do this:
Code: | #pin_select SCL1OUT = PIN_C3
#pin_select SCL1IN = PIN_C3
#pin_select SDA1OUT = PIN_C4
#pin_select SDA1IN = PIN_C4
#use I2C(slave, sda=PIN_C4, scl=PIN_C3, address=0xa0) |
|
|
|
PA_papa_wolf
Joined: 11 Nov 2019 Posts: 9
|
|
Posted: Sun Oct 25, 2020 1:35 am |
|
|
I was able to solve a problem. It is very kind of you. |
|
|
|
|
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
|