Mikroc – ABL electronic PIC Microcontrollers PIC16 User Manual

Page 178

Advertising
background image

mikroC - C Compiler for Microchip PIC microcontrollers

mikroC

making it simple...

170

MikroElektronika: Development tools - Books - Compilers

page

Next example waits until the CF card is inserted, and when plugged, it creates 5 text files on the
card. Each file will be appended the same timestamp.

unsigned short

index;

unsigned

i1;

char

*fname, *ext;

void

Init(void) {

TRISC = 0;

// PORTC is output

Cf_Init(PORTB, PORTD);

// Initialize ports

do

nop;

while

(!Cf_Detect());

// Wait until CF card is inserted

Delay_ms(50);

// Wait until the card is stabilized

}

//~

void

main() {

ext = "TXT";

index = 0;

// Index of file to be written

while

(index < 5) {

PORTC = 0;

Init();

PORTC = index;

Cf_File_Write_Init();

// Initialization for writing to new file

i1 = 0;

// Write 50,000 bytes to file

while

(i1 < 50000) {

Cf_File_Write_Byte(48 + index);

i1++;

}

fname = "MY_TEST1";

// Name must be 8 character long in uppercase

fname[8] = 48 + index;

// Ensure that files have different name

Cf_Set_File_Date(2005,1,1,0,0,0);

// Append a timestamp

Cf_File_Write_Complete(fname, ext);

// Close the file

index++;

}

PORTC = 0xFF;

}

//~!

Advertising
This manual is related to the following products: