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

  • 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 237
MikroElektronika:
Development
tools
-
Books
-
Compilers
230
page
mikroC
- C Compiler for Microchip PIC microcontrollers
mikroC
making it simple...
Library Example
The following code tests MMC library routines. First, we fill the buffer with 512 “M” characters
and write it to sector 56; then we repeat the sequence with character “E” at sector 56. Finally, we
read the sectors 55 and 56 to check if the write was successful.
unsigned i;
unsigned short tmp;
unsigned short data[512];
void main() {
Usart_Init(9600);
// Wait until MMC is initialized
while (Mmc_Init(&PORTC, 2)) ;
// Fill the buffer with the 'M' character
for (i = 0; i <= 511; i++) data[i] = "M";
// Write it to MMC card, sector 55
tmp = Mmc_Write_Sector(55, data);
// Fill the buffer with the 'E' character
for (i = 0; i <= 511; i++) data[i] = "E";
// Write it to MMC card, sector 56
tmp = Mmc_Write_Sector(56, data);
/** Now to check sectors 55 and 56 **/
// Read from sector 55
tmp = Mmc_Read_Sector(55, data);
// Send 512 bytes from buffer to USART
if (tmp == 0)
for (i = 0; i < 512; i++) Usart_Write(data[i]);
// Read from sector 56
tmp = Mmc_Read_Sector(56, data);
// Send 512 bytes from buffer to USART
if (tmp == 0)
for (i = 0; i < 512; i++) Usart_Write(data[i]);
}
//~!
Vue de la page 237
1 2 ... 233 234 235 236 237 238 239 240 241 242 243 ... 311 312

Commentaires sur ces manuels

Pas de commentaire