|
|
View previous topic :: View next topic |
Author |
Message |
Loic
Joined: 26 Feb 2004 Posts: 1
|
Problem on I2C master 16F877 |
Posted: Thu Feb 26, 2004 4:37 am |
|
|
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
|
|
Posted: Thu Feb 26, 2004 7:19 am |
|
|
Hi Loic,
try the following:
1. Code: | #fuses HS, NOWDT, NOPUT, NOLVP, NOBROWNOUT, NODEBUG |
2. don't forget that does also disable the i2c module (you are using the force_hw!).
Regards,
Markus |
|
|
Guest
|
|
Posted: Thu Feb 26, 2004 1:36 pm |
|
|
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
|
|
Posted: Thu Feb 26, 2004 5:31 pm |
|
|
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. |
|
|
|
|
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
|