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

How to use #pin_select

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



Joined: 07 Apr 2014
Posts: 1

View user's profile Send private message

How to use #pin_select
PostPosted: Thu Apr 21, 2016 5:30 pm     Reply with quote

In my project in setting I2c through CCS WIZARD I have this error when compiling.....

Option invalid. Wrong pin for H/W.

This my code:
file I2C.h
Code:

#include <16LF1704.h>
#device ADC=10
#use delay(internal=32MHz)
#use STANDARD_IO( C )

#define Device_SDA PIN_C1
#define Device_SLC  PIN_C0

#use i2c(Slave,Slow,sda=Device_SDA,scl=Device_SLC,address=0x10)

file I2C.c
Code:

#include <I2C.h>

void main()
{

   while(TRUE)
   {
      //TODO: User Code
   }

}
PCM programmer



Joined: 06 Sep 2003
Posts: 20099

View user's profile Send private message

PostPosted: Thu Apr 21, 2016 8:47 pm     Reply with quote

Put this above the #use i2c() statement:
Code:
#pin_select SCL1OUT = PIN_C0
#pin_select SCL1IN  = PIN_C0

#pin_select SDA1OUT = PIN_C1
#pin_select SDA1IN  = PIN_C1
Ttelmah



Joined: 11 Mar 2010
Posts: 12511

View user's profile Send private message

PostPosted: Fri Apr 22, 2016 4:33 am     Reply with quote

This is one that is approaching 'FAQ' status. Perhaps ought to be a sticky at the top of the forum.

On all chips supporting 'selectable' peripheral pins (distinct from 'fuse re-mappable' pins), you must tell the compiler what pins the peripheral is using before setting the peripheral up.

Just to expand on PCM_programmer's answer, I'd also suggest using the peripheral name, rather than the pins in the #use statement. So:
Code:


#include <16LF1704.h>
#device ADC=10
#use delay(internal=32MHz)
#use STANDARD_IO( C )

#pin_select SCL1OUT = PIN_C0
#pin_select SCL1IN  = PIN_C0

#pin_select SDA1OUT = PIN_C1
#pin_select SDA1IN  = PIN_C1

#use i2c(Slave,I2C1,address=0x10)


Also get rid of 'slow'. A _slave_ does not have a speed in general. The speed is controlled and settable in the master only.
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