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

Problem on I2C master 16F877

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



Joined: 26 Feb 2004
Posts: 1

View user's profile Send private message

Problem on I2C master 16F877
PostPosted: Thu Feb 26, 2004 4:37 am     Reply with quote

Hi, I have write this code, but nothing happen on I2C pin I don't understand why! Could somebody help-me?

This is my master code

#include <16F877A.h>
#use delay(clock=16000000)
#fuses HS,NOWDT,NOPUT,NOLVP, NOBROWNOUT
#use i2c(master,sda=PIN_C4,scl=PIN_C3,force_hw,fast) // Hardware i2c
#include <protocol_i2c.h>
#define SLAVE_ADDR 0x40
void main() {

set_tris_b(0x00); //all output
// Program loops continuously
output_high(pin_b7);
while(1) {
output_low(pin_b6);
i2c_start();
output_low(pin_b7);
i2c_write(SLAVE_ADDR);
i2c_write(ilcd1);
i2c_write(Start_pos);
i2c_write(0x09);
i2c_stop();
delay_us(50);

output_High(pin_b6);
}
}

One thing strange is that pin B6 go high and low but pin C4 & C3 believe high.

Excuse my bad english and thanks to help me.

Lo�c
Markus



Joined: 30 Oct 2003
Posts: 13

View user's profile Send private message

PostPosted: Thu Feb 26, 2004 7:19 am     Reply with quote

Hi Loic,

try the following:

1.
Code:
#fuses HS, NOWDT, NOPUT, NOLVP, NOBROWNOUT, NODEBUG


2. don't forget that
Code:
setup_spi(FALSE);
does also disable the i2c module (you are using the force_hw!).

Regards,
Markus
Guest








PostPosted: Thu Feb 26, 2004 1:36 pm     Reply with quote

Hi, thank you Markus for your answer. But there is two problem:
first one : my version of CCS (IDE 3.14, PCB & PCM 3.094) don't know "nodebug"!
second : if i'm don't use "force_hw", SCL is alwais low! (Of course I use pull-up!)

Regards,
Lo�c
Markus



Joined: 30 Oct 2003
Posts: 13

View user's profile Send private message

PostPosted: Thu Feb 26, 2004 5:31 pm     Reply with quote

Hi Loic,

is this directive supported by your compiler version? (sorry, never worked with Ver. 3.094)

Code:

#device ICD = FALSE


Otherwise try clearing the DEBUG bit (bit 11) of register 14-1 (p. 146 in 16F87xA datasheet pdf) by hand.

Hope this helps,
Markus

PS: Pins RB3, RB6 and RB7 are reserved for the In-Circiut Debugger (ICD), you have to turn it off to use them as normal IO-Ports.
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