CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

I cannot use I2C.(16F18854)

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
PA_papa_wolf



Joined: 11 Nov 2019
Posts: 9

View user's profile Send private message

I cannot use I2C.(16F18854)
PostPosted: Sun Oct 25, 2020 12:45 am     Reply with quote

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

View user's profile Send private message

PostPosted: Sun Oct 25, 2020 1:04 am     Reply with quote

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

View user's profile Send private message

PostPosted: Sun Oct 25, 2020 1:35 am     Reply with quote

I was able to solve a problem. It is very kind of you.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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