ABL electronic PIC16 Personal Computer User Manual


 
MikroElektronika:
Development
tools
-
Books
-
Compilers
16 9
page
mikroC
- C Compiler for Microchip PIC microcontrollers
mikroC
making it simple...
Library Example
The following example writes 512 bytes at sector no.590, and then reads the data and prints on
PORTC for a visual check.
unsigned i;
void main() {
TRISC = 0;
// PORTC is output
Cf_Init(PORTB, PORTD);
// Initialize ports
do nop;
while (!Cf_Detect());
// Wait until CF card is inserted
Delay_ms(500);
Cf_Write_Init(590, 1);
// Initialize write at sector address 590
// Write 512 bytes to sector (590)
for (i = 0; i < 512; i++) Cf_Write_Byte(i + 11);
PORTC = 0xFF;
Delay_ms(1000);
Cf_Read_Init(590, 1);
// Initialize read at sector address 590
// Read 512 bytes from sector (590)
for (i = 0; i < 512; i++) {
PORTC = Cf_Read_Byte();
// Read byte and display on PORTC
Delay_ms(1000);
}
}