mikroElektronika PIC Microcontrollers PIC12 User Manual page 178

Mikroc user's manual
Table of Contents

Advertisement

mikroC - C Compiler for Microchip PIC microcontrollers
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;
Cf_Init(PORTB, PORTD);
do nop;
while (!Cf_Detect());
Delay_ms(50);
} //~
void main() {
ext = "TXT";
index = 0;
while (index < 5) {
PORTC = 0;
Init();
PORTC = index;
Cf_File_Write_Init();
i1 = 0;
// Write 50,000 bytes to file
while (i1 < 50000) {
Cf_File_Write_Byte(48 + index);
i1++;
}
fname = "MY_TEST1";
fname[8] = 48 + index;
Cf_Set_File_Date(2005,1,1,0,0,0);
Cf_File_Write_Complete(fname, ext);
index++;
}
PORTC = 0xFF;
} //~!
page
170
// PORTC is output
// Initialize ports
// Wait until CF card is inserted
// Wait until the card is stabilized
// Index of file to be written
// Initialization for writing to new file
// Name must be 8 character long in uppercase
// Ensure that files have different name
// Append a timestamp
// Close the file
MikroElektronika: Development tools - Books - Compilers
mikroC
making it simple...

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the PIC Microcontrollers PIC12 and is the answer not in the manual?

This manual is also suitable for:

Pic microcontrollers pic16Pic microcontrollers pic18

Table of Contents