Datasheet
Programming PIC Microcontrollers in BASIC - mikroElektronika
Here’s an example for using Compact Flash card from BASIC. A set of files is written on CF card. 
This can be checked later by plugging the CF card on a PC or a digital camera. Observe the way the 
file is being written:
● First, write-to-file is initialized, telling to PIC that all consecutive CF_File_Write_Byte 
instructions will write to a new file; 
● Then, actual write of data is performed (with CF_File_Write_Byte); 
● Finally, finish of write-to-file cycle is signallized with call to CF_File_Write_Complete 
routine. At that moment, the newly created file is given its name. 
program CompactFlash_File
' for PIC18
dim i1 as word
dim index as byte
dim fname as char[9]
dim ext as char[4]
sub procedure Init
 TRISC = 0 ' PORTC is output. We'll 
use it only to signal
 ' end of our program.
 CF_Init_Port(PORTB, PORTD) ' Initialize ports
do
 nop
loop until CF_DETECT(PORTB) = true ' Wait until CF card is 
inserted
Delay_ms(50) ' Wait for a while until 
the card is stabilized
end sub ' i.e. its power supply 
is stable and CF card
 ' controller is on
main:
 ext = "txt" ' File extensions will be 
"txt"
 index = 0 ' Index of file to be 
written
http://www.mikroelektronika.co.yu/english/product/books/picbasicbook/08.htm (9 sur 12)05/11/2004 02:28:30










