User manual
mikroBasic PRO for PIC32
MikroElektronika
275
le_contents[0] = loop1 div 10 + 48
le_contents[1] = loop1 mod 10 + 48
Cf_Fat_Write(le_contents, LINE_LEN-1) ‘ write data to the assigned le
next loop1
end sub
‘-------------- Creates many new les and writes data to them
sub procedure M_Create_Multiple_Files()
for loop2 = “B” to “Z”
UART1_Write(loop2) ‘ this line can slow down the performance
lename[7] = loop2 ‘ set lename
Cf_Fat_Set_File_Date(2005,6,21,10,35,0) ‘ Set le date & time info
Cf_Fat_Assign(lename, 0xA0) ‘ nd existing le or create a new one
Cf_Fat_Rewrite() ‘ To clear le and start with new data
for loop1 = 1 to 44
le_contents[0] = loop1 div 10 + 48
le_contents[1] = loop1 mod 10 + 48
Cf_Fat_Write(le_contents, LINE_LEN-1) ‘ write data to the assigned le
next loop1
next loop2
end sub
‘-------------- Opens an existing le and rewrites it
sub procedure M_Open_File_Rewrite()
lename[7] = “C” ‘ Set lename for single-le tests
Cf_Fat_Assign(lename, 0)
Cf_Fat_Rewrite()
for loop1 = 1 to 55
le_contents[0] = byte(loop1 div 10 + 48)
le_contents[1] = byte(loop1 mod 10 + 48)
Cf_Fat_Write(le_contents, LINE_LEN-1) ‘ write data to the assigned le
next loop1
end sub
‘-------------- Opens an existing le and appends data to it
‘ (and alters the date/time stamp)
sub procedure M_Open_File_Append()
lename[7] = “B”
Cf_Fat_Assign(lename, 0)
Cf_Fat_Set_File_Date(2009, 1, 23, 17, 22, 0)
Cf_Fat_Append
le_contents = “ for mikroElektronika 2009” ‘ Prepare le for append
le_contents[26] = 13 ‘ CR
le_contents[27] = 10 ‘ LF
Cf_Fat_Write(le_contents, 27) ‘ Write data to assigned le
end sub
‘-------------- Opens an existing le, reads data from it and puts it to USART
sub procedure M_Open_File_Read()
lename[7] = “B”
Cf_Fat_Assign(lename, 0)
Cf_Fat_Reset(size) ‘ To read le, procedure returns size of le
while size > 0
Cf_Fat_Read(character)
UART1_Write(character) ‘ Write data to USART
Dec(size)
wend