User manual

Table Of Contents
mikroC PRO for PIC32
MikroElektronika
419
Library Example
The example demonstrates use of the Software I²C Library. The PIC32 MCU is connected (SCL, SDA pins) to PCF8583
RTC (real-time clock). Program sends date/time to RTC.
Copy Code To Clipboard
char seconds, minutes, hours, day, month, year; // Global date/time variables
// Software I2C connections
sbit Soft_I2C_Scl at RF3_bit;
sbit Soft_I2C_Sda at RF4_bit;
sbit Soft_I2C_Scl_Direction at TRISF3_bit;
sbit Soft_I2C_Sda_Direction at TRISF4_bit;
// End Software I2C connections
// LCD module connections
sbit LCD_RS at LATB2_bit;
sbit LCD_EN at LATB3_bit;
sbit LCD_D4 at LATB4_bit;
sbit LCD_D5 at LATB5_bit;
sbit LCD_D6 at LATB6_bit;
sbit LCD_D7 at LATB7_bit;
sbit LCD_RS_Direction at TRISB2_bit;
sbit LCD_EN_Direction at TRISB3_bit;
sbit LCD_D4_Direction at TRISB4_bit;
sbit LCD_D5_Direction at TRISB5_bit;
sbit LCD_D6_Direction at TRISB6_bit;
sbit LCD_D7_Direction at TRISB7_bit;
// End LCD module connections
//--------------------- Reads time and date information from RTC (PCF8583)
void Read_Time() {
Soft_I2C_Start(); // Issue start signal
Soft_I2C_Write(0xA0); // Address PCF8583, see PCF8583 datasheet
Soft_I2C_Write(2); // Start from address 2
Soft_I2C_Start(); // Issue repeated start signal
Soft_I2C_Write(0xA1); // Address PCF8583 for reading R/W=1
seconds = Soft_I2C_Read(1); // Read seconds byte
minutes = Soft_I2C_Read(1); // Read minutes byte
hours = Soft_I2C_Read(1); // Read hours byte
day = Soft_I2C_Read(1); // Read year/day byte
month = Soft_I2C_Read(0); // Read weekday/month byte
Soft_I2C_Stop(); // Issue stop signal
}
//-------------------- Formats date and time
void Transform_Time() {