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 CCS Technical Support

i2c multimaster problem
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
cheehow



Joined: 15 Sep 2010
Posts: 28

View user's profile Send private message

PostPosted: Thu Sep 23, 2010 1:29 am     Reply with quote

I have modified my master code ...... please help me to check whether my master code have any problem or not ??


++++++++++++++++++++++++
cheehow:

No double posts !

Your other post:
http://www.ccsinfo.com/forum/viewtopic.php?t=43620

-- Forum Moderator
++++++++++++++++++++++++


master code :
Code:

#include "C:\Users\Tan Chee How\Desktop\testing I2C\master.h"

#define Device_SDA PIN_C3
#define Device_SCL PIN_C4
#USE I2C (MASTER, SDA=Device_SDA, SCL=Device_SCL)
#USE fast_io(C)
#USE standard_io(B)
#USE fast_io(D)
int x;
BYTE Data;

void main()
{
SET_TRIS_C(0X00);
SET_TRIS_D(0XFF);
OUTPUT_B(0X00);


WHILE(TRUE)
{

for(x=0x00; x<0x0A; x++)
{
i2c_start();
i2c_write(0xA0);
i2c_write(x);
i2c_write(0X0A-x);
i2c_stop();
delay_ms(100);

i2c_start();
i2c_write(0xA1);
Data=i2c_read(0);
i2c_stop();
delay_ms(100);
}

if(INPUT(PIN_D1))
OUTPUT_HIGH(PIN_B6);
delay_ms(500);
OUTPUT_LOW(PIN_B6);
delay_ms(500);
OUTPUT_HIGH(PIN_B7);
delay_ms(500);
OUTPUT_LOW(PIN_B7);

}

}


The slave code is taken from the ccs c compiler example one (EX_SLAVE.C) and modified a little bit.
Code:

#include "C:\Users\Tan Chee How\Desktop\testing I2C\slave.h"

#define Device_SDA PIN_C3
#define Device_SCL PIN_C4
#use i2c (slave, SDA= Device_SDA, SCL=Device_SCL,address=0xA0, FORCE_HW)
#INT_SSP



BYTE address, buffer[0x10];

void ssp_interupt ()
{
BYTE incoming, state;

state = i2c_isr_state();

if(state < 0x80)
{
incoming = i2c_read();
if(state == 1)
address = incoming;
if(state == 2)
buffer[address] = incoming;
}
if(state == 0x80)
{
i2c_write(buffer[address]);
}
}

void main ()
{
SET_TRIS_C(0XFF);
SET_TRIS_B(0X00);
SET_TRIS_D(0X00);
OUTPUT_B(0X00);
enable_interrupts(GLOBAL);
enable_interrupts(INT_SSP);

while (TRUE) {}
}

Please help me to check whether I have any problem for my code or not ... thxs for checking =)
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
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