cipi-cips
Member level 4
- Joined
- Jun 30, 2008
- Messages
- 76
- Helped
- 2
- Reputation
- 4
- Reaction score
- 1
- Trophy points
- 1,288
- Activity points
- 1,867
#include <pic18f4550.h>
#include <i2c.h>
#define OUT PORTDbits.RD7
void main (main)
{
TRISDbits.TRISD7 = 0;
OpenI2C(MASTER, SLEW_OFF);
SSPADD = 0x31; // determinate baud rate (20Mhz xtal, and 100Khz rate), with this formula I got ((Fos/4)/100Khz)-1.
StartI2C();
IdleI2C();
WriteI2C(0xA0); //this is control byte
IdleI2C();
WriteI2C(0x01); //write at this address
IdleI2C();
WriteI2C(0xFF); //write data 255
IdleI2C();
StopI2C();
StartI2C();
IdleI2C();
WriteI2C(0xA1); //this is control byte
IdleI2C();
number = Read2C(); //read
IdleI2C();
StopI2C();
if (number == 255)
{
OUT = 1;
}
else
{
OUT = 0;
}
while(1);
}
Check ACK signal during Reading process
What is EEAckPolling(), a built-in compiler function? Presumed it does correct acknowledge polling, it should finish within 5 ms. Otherwise there's something wrong.WP pin is tied to ground, do you probably now why does PIC cant leave this loop while(EEAckPolling(0xA));.
HI there
I have put resistors both on SDK and SCL to the VCC, (I found on internet that 24C32 wont work without that).
Second I put SDA and SCL both LOW at start (TRISBbits.TRISB0 = 0 and TRISBbits.TRISB1 = 0).
Whit these settings I get something on the output, but when ever I change data output is always the same.
Any help?
What is EEAckPolling(), a built-in compiler function? Presumed it does correct acknowledge polling, it should finish within 5 ms. Otherwise there's something wrong.
If (PIR2bits.BCLIF)
{
return (-1)
}
Peripheral address correct? and How do you prove peripherals OK?
How do you prove peripherals OK?
may be speed very fast
SSPADD = 119 //100Khz
SSPADD = 29 //400Khz
SSPADD = 11 //1Mhz
What resistor values did you use ?
What pins on 24LC32 you connect
That's right, but some question are already answered by the waveforms. If the EEPROM does ACK the commands, you can expect it's addressed correctly, isn't it?A0, A1 ,A2 Code should be set according to the circuit
First Those yellow is not output,it just Write Process,It has a relationship with your code!
Second You do not know what I mean,A0, A1 ,A2 Code should be set according to the circuit !
Instead of Default Address from code!
Do you understand ?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?