Datasheet
if (size <> 0) then
LongIntToStr(size, fat_txt)
UART1_Write_Text(fat_txt)
for i=0 to 4999
Mmc_Write_Sector(size, Buffer)
size = size + 1
UART1_Write(".")
next i
end if
end sub
'-------------- Main. Uncomment the sub function(s) to test the
desired operation(s)
main:
FAT_TXT = "FAT16 not found"
file_contents = "XX MMC/SD FAT16 library by Anton Rieckert#"
file_contents[41] = 10 ' newline
filename = "MIKRO00xTXT"
' we will use PORTC to signal test end
DDRC = 0xFF
PORTC = 0
UART1_Init(19200)
'delay_ms(100) ' Set up USART for file reading
UART1_Write_Text("Start")
'--- Init the FAT library
SPI1_Init_Advanced(_SPI_MASTER, _SPI_FCY_DIV128, _SPI_CLK_LO_LEADING)
Spi_Rd_Ptr = @SPI1_Read
' use fat16 quick format instead of init routine if a formatting
is needed
if Mmc_Fat_Init() = 0 then
PORTC = 0xF0
' reinitialize spi at higher speed
SPI1_Init_Advanced(_SPI_MASTER, _SPI_FCY_DIV2, _SPI_CLK_LO_LEADING)
'--- signal start-of-test
'--- test sub functions
Create_New_File
Create_Multiple_Files
Open_File_Rewrite
Open_File_Append
Open_File_Read
Delete_File
Test_File_Exist
M_Create_Swap_File()
UART1_Write("e")
else
UART1_Write_Text(FAT_TXT)
end if
'--- signal end-of-test
PORTC = $0F
UART1_Write_Text("End")
end.'~!
279
MIKROELEKTRONIKA - SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Libraries
mikroBasic PRO for AVR
CHAPTER 6