Datasheet

'-------------- Writes string to USART
sub procedure Write_Str(dim byref ostr as byte[2])
dim
i as byte
i = 0
while ostr[i] <> 0
UART1_Write (ostr[i])
Inc(i)
wend
UART1_Write($0A)
end sub'~
'-------------- Creates new file and writes some data to it
sub procedure Create_New_File
filename[7] = "A" ' Set filename for single-file
tests
Mmc_Fat_Assign(filename, 0xA0) ' Will not find file and then cre-
ate file
Mmc_Fat_Rewrite ' To clear file and start with
new data
for loop_ = 1 to 99 ' We want 5 files on the MMC
card
UART1_Write(".")
file_contents[0] = loop_ div 10 + 48
file_contents[1] = loop_ mod 10 + 48
Mmc_Fat_Write(file_contents, 42) ' write data to the assigned
file
next loop_
end sub'~
'-------------- Creates many new files and writes data to them
sub procedure Create_Multiple_Files
for loop2 = "B" to "Z"
UART1_Write(loop2) ' this line can slow down
the performance
filename[7] = loop2 ' set filename
Mmc_Fat_Assign(filename, 0xA0) ' find existing file or cre-
ate a new one
Mmc_Fat_Rewrite ' To clear file and start
with new data
for loop_ = 1 to 44
file_contents[0] = byte(loop_ div 10 + 48)
file_contents[1] = byte(loop_ mod 10 + 48)
Mmc_Fat_Write(file_contents, 42) ' write data to the assigned
file
next loop_
next loop2
end sub'~
276
MIKROELEKTRONIKA - SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Libraries
mikroBasic PRO for AVR
CHAPTER 6