kimsan
Newbie level 5
I m just learning MikroC with pic 16F887. I try to use MikroC example to simulate with proteus. but it doesn't work i don know why?
please help me. when i compile it succes but when i try to simulate with proteus it doen't show me any working. By using mikroc function how may clock oscilator should we used?
/* In this example, PIC MCU is connected to 24C02 EEPROM via SCL and SDA pins. The program
sends one byte of data to the EEPROM address 2. Then, it reads that data via I2C from
EEPROM and sends it to PORTB in order to check if the data was successfully written. */
void main(){
ANSEL = ANSELH = PORTB = TRISB = 0; // All pins are digital. PORTB pins are outputs.
I2C1_Init(100000); // Initialize I2C with desired clock
I2C1_Start(); // I2C start signal
I2C1_Wr(0xA2); // Send byte via I2C (device address + W)
I2C1_Wr(2); // Send byte (address of EEPROM location)
I2C1_Wr(0xF0); // Send data to be written
I2C1_Stop(); // I2C stop signal
Delay_100ms();
I2C1_Start(); // I2C start signal
I2C1_Wr(0xA2); // Send byte via I2C (device address + W)
I2C1_Wr(2); // Send byte (data address)
I2C1_Repeated_Start(); // Issue I2C signal repeated start
I2C1_Wr(0xA3); // Send byte (device address + R)
PORTB = I2C1_Rd(0u); // Read the data (NO acknowledge)
I2C1_Stop(); // I2C stop signal
}
please help me. when i compile it succes but when i try to simulate with proteus it doen't show me any working. By using mikroc function how may clock oscilator should we used?
/* In this example, PIC MCU is connected to 24C02 EEPROM via SCL and SDA pins. The program
sends one byte of data to the EEPROM address 2. Then, it reads that data via I2C from
EEPROM and sends it to PORTB in order to check if the data was successfully written. */
void main(){
ANSEL = ANSELH = PORTB = TRISB = 0; // All pins are digital. PORTB pins are outputs.
I2C1_Init(100000); // Initialize I2C with desired clock
I2C1_Start(); // I2C start signal
I2C1_Wr(0xA2); // Send byte via I2C (device address + W)
I2C1_Wr(2); // Send byte (address of EEPROM location)
I2C1_Wr(0xF0); // Send data to be written
I2C1_Stop(); // I2C stop signal
Delay_100ms();
I2C1_Start(); // I2C start signal
I2C1_Wr(0xA2); // Send byte via I2C (device address + W)
I2C1_Wr(2); // Send byte (data address)
I2C1_Repeated_Start(); // Issue I2C signal repeated start
I2C1_Wr(0xA3); // Send byte (device address + R)
PORTB = I2C1_Rd(0u); // Read the data (NO acknowledge)
I2C1_Stop(); // I2C stop signal
}