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

  • 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 167
mikroC
- C Compiler for Microchip PIC microcontrollers
mikroC
making it simple...
160
MikroElektronika:
Development
tools
-
Books
-
Compilers
page
// .. continued
// Initialize external CAN module
CANSPIInitialize(1,1,3,3,1,aa);
// Set CANSPI to CONFIG mode
CANSPISetOperationMode(CAN_MODE_CONFIG,_TRUE);
ID = -1;
// Set all mask1 bits to ones
CANSPISetMask(CAN_MASK_B1,id,CAN_CONFIG_XTD_MSG);
// Set all mask2 bits to ones
CANSPISetMask(CAN_MASK_B2,id,CAN_CONFIG_XTD_MSG);
// Set id of filter B1_F1 to 12111
CANSPISetFilter(CAN_FILTER_B2_F4,12111,CAN_CONFIG_XTD_MSG);
// Set CANSPI to NORMAL mode
CANSPISetOperationMode(CAN_MODE_NORMAL,_TRUE);
while (1) {
zr = CANSPIRead(&id , &Data , &len, &aa2);
// Receive data, if any
if (id == 12111 & zr ) {
PORTB = data[0]++ ;
// Output data on PORTB
id = 3;
Delay_ms(500);
// Send incremented data back
CANSPIWrite(id,&data,1,aa1);
// If message contains 2 data bytes, output second byte at PORTD
if (len == 2) PORTD = data[1];
}
}
}//~!
Vue de la page 167
1 2 ... 163 164 165 166 167 168 169 170 171 172 173 ... 311 312

Commentaires sur ces manuels

Pas de commentaire