mikroC
making it simple...
Library Example
mikroC - C Compiler for Microchip PIC microcontrollers
/* The example demonstrates use of Software I²C Library.
PIC MCU is connected (SCL, SDA pins) to PCF8583 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 |
}//~! |
|
|
| page |
|
MikroElektronika: Development tools - Books - Compilers | 257 | ||
|
|