Abl-electronic PIC Microcontrollers PIC16 Manuel d'utilisateur Page 265

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 312
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 264
MikroElektronika:
Development
tools
-
Books
-
Compilers
257
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
}
//~!
Vue de la page 264
1 2 ... 260 261 262 263 264 265 266 267 268 269 270 ... 311 312

Commentaires sur ces manuels

Pas de commentaire