ABL electronic PIC12 Personal Computer User Manual


 
MikroElektronika:
Development
tools
-
Books
-
Compilers
25 7
page
mikroC
- C Compiler for Microchip PIC microcontrollers
mikroC
making it simple...
Library Example
/* The example demonstrates use of Software I²C Library.
PIC MCU is connected (SCL, SDA pins) to PCF8583 RTC (real-time clock).
Program sends date data to RTC. */
void main() {
Soft_I2C_Config(&PORTD, 4,3);
// Initialize full master mode
Soft_I2C_Start();
// Issue start signal
Soft_I2C_Write(0xA0);
// Address PCF8583
Soft_I2C_Write(0);
// Start from word at address 0 (config word)
Soft_I2C_Write(0x80);
// Write 0x80 to config. (pause counter...)
Soft_I2C_Write(0);
// Write 0 to cents word
Soft_I2C_Write(0);
// Write 0 to seconds word
Soft_I2C_Write(0x30);
// Write 0x30 to minutes word
Soft_I2C_Write(0x11);
// Write 0x11 to hours word
Soft_I2C_Write(0x30);
// Write 0x24 to year/date word
Soft_I2C_Write(0x08);
// Write 0x08 to weekday/month
Soft_I2C_Stop();
// Issue stop signal
Soft_I2C_Start();
// Issue start signal
Soft_I2C_Write(0xA0);
// Address PCF8530
Soft_I2C_Write(0);
// Start from word at address 0
Soft_I2C_Write(0);
// Write 0 to config word (enable counting)
Soft_I2C_Stop();
// Issue stop signal
}
//~!