Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

CCS-IDE wizard for I2C code

Status
Not open for further replies.

tom_hanks

Full Member level 5
Joined
Aug 28, 2003
Messages
243
Helped
14
Reputation
28
Reaction score
1
Trophy points
1,298
Activity points
1,571
i2c ccs

Hi,
Does any one is using CCS-IDE for PIC programming.....

I have written a code for I2C, but it is not giving the required result...

i was thining to see the code generated from CCS-IDE wizard....

if any one can generate the code for PIC16F818, then it would be helpfull for me for refrence...
 

ccs i2c

Check out the examples folder of CCS. It has large number of I2C codes for 24Cxx EEPROM and other peripherals.
 

ccs i2c slave

dear cmos,

thank you...
i have already ckech those file...but they are not helpfull...
 

ccs ide

I am using a PIC as a I2C bridge...

for slave, i am using hardware and for master I am using software I2c..
software one is working fine....
while the hardware I2C is not working properly...
this is the code for HW..
once master accumlates the data, it will store and pass it to slave hw interface...

//===================
#INT_SSP
void i2c_interrupt_handler(void) // Interrupt handler for slave I2C
{
#use i2c(SLAVE, SDA=PIN_B1, SCL=PIN_B4, address=0x60, FORCE_HW)
BYTE state;
state = i2c_isr_state();

if(state == 0x80) // Master is requesting data
{
for (i=0;i<4;++i)
{
i2c_write(ADC_store); // Low byte of command
i2c_write(ADC_store>>8); // High byte of command
}
}
else if(state < 0x80) // Master is sending data
{
recvx = i2c_read();
ADC_store[1] = recvx;
}
}
 

ccs i2c examples

I've never had a PIC that would work as both master and slave on 2 different I2C buses. Even if CCS compiler can't handle multiple #use i2c(...) directives, you can write your own bit-banged software I2C code for the bus, where PIC is a master, and use only one #use i2c(..., slave) for the bus, where the PIC is a slave.

I would recommend the specialized CCS forum (if you don't know about it already) https://www.ccsinfo.com/forum . I vaguely recall that a situation similar to yours have been discussed there, so you might be able to simply find the existing threads. There are lots of I2C bit-banging codes too.
 

i2c interrupt ccs

Look at the CCS help, you will find The SLAVE mode should only be used with the build-in SSP. This means :
#use I2C(slave,sda=PIN_C4,scl=PIN_C3 address=0x60,FORCE_HW)

You can only use PIN_C4 and PIN_C3 not the B1,B4
 

i2c_isr_state

are said:
Look at the CCS help, you will find The SLAVE mode should only be used with the build-in SSP. This means :
#use I2C(slave,sda=PIN_C4,scl=PIN_C3 address=0x60,FORCE_HW)

You can only use PIN_C4 and PIN_C3 not the B1,B4

One more thing in your code seems peculiar: you switch into a slave mode inside a slave interrupt. That's a catch-22.
 

i2c ccs slave

yes, i got the help from the CCs Forum..
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top