Zdravím, nemáte někdo zkušenosti se čtením a zápisem souboru na SD kartu v bascomu prosím. Popřípadě klidně uvítám pokud by někco byl odćhoten jak s kartou komunikovat nez knihoven. To znamená zvládnout FAT systém.
Díky, s pozdravem jenda
SD karta
Moderátori: psichac, Moderátori
Re: SD karta
Ahoj, takyto dotaz som tu mal pred 2 mi rokmi a vidim, ze tam dodnes je 0 reakcii.
nieco som vtedy skusal a zapis mi myslim fungoval
tu je kus kodu ak ti to pomoze. (nieje cely)
$include "Config_MMC.bas" 'Include AVR-DOS Configuration and library
$include "Config_AVR-DOS.BAS"
'***************************************************************************
Declare Sub Inc_sd
Declare Sub Record_file(byval Uloz_data2 As String )
Declare Sub Testerrors(byval N As Byte )
Cls
Lcd "start"
Do
Cls
If Sd_in_slot = 1 Then 'karta SD neni ve slotu
Locate 1 , 1
Lcd "Nevlozena karta"
Else 'karta SD je ve slotu
Locate 1 , 1
Lcd "Vlozena karta"
Uloz_data = "test;" + Str(s)
Uloz_data = Uloz_data + ";"
Incr S
Call Inc_sd()
Locate 2 , 1
Lcd Uloz_data
End If
Wait 5
Toggle Led
Loop
End
'xxxxxxxxxxxxxxxxxxxxxxxxxxx zapis na SD kartu xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Sub Inc_sd
Gbdriveerror = Driveinit() 'Inciace karty
If Gbdriveerror = 0 Then
Btemp1 = Initfilesystem(1) ' Partition 1
If Btemp1 <> 0 Then
Cls
Lcd "error: " ; Btemp1
Locate 2 , 1
Lcd "at Init f. system"
Wait 2
Else
Locate 1 , 6
Lcd "S"
Call Record_file(uloz_data)
Locate 1 , 6
Lcd " "
End If
Else
Print "Error during Drive Init: " ; Gbdriveerror
Cls
Lcd "Err Init:" ; Gbdriveerror
Wait 2
End If
End Sub
Sub Record_file(byval Uloz_data2 As String )
Reset Watchdog
Open "Teplota1.csv" For Append As #1
Write #1 , Uloz_data2 ' write is also supported
Flush #1
Close #1
Call Testerrors(1)
Reset Watchdog
Wait 1
Locate 2 , 6
Lcd "O"
Reset Watchdog
Wait 1
Locate 2 , 6
Lcd " "
Reset Watchdog
End Sub
'***************************************************************************
'* Debug routine, test AVR-DOS error flag. If errors found signals user
'* flashing a LED and writes the error position code
'***************************************************************************
Sub Testerrors(byval N As Byte )
While Gbdoserror <> 0
Cls
Lcd "err:" ; Gbdoserror ; " posit:" ; N
Waitms 100
Wend
End Sub
' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx end SD karta xxxxxxxxxxxxxxxxxxxxxxxxxxx
nieco som vtedy skusal a zapis mi myslim fungoval
tu je kus kodu ak ti to pomoze. (nieje cely)
$include "Config_MMC.bas" 'Include AVR-DOS Configuration and library
$include "Config_AVR-DOS.BAS"
'***************************************************************************
Declare Sub Inc_sd
Declare Sub Record_file(byval Uloz_data2 As String )
Declare Sub Testerrors(byval N As Byte )
Cls
Lcd "start"
Do
Cls
If Sd_in_slot = 1 Then 'karta SD neni ve slotu
Locate 1 , 1
Lcd "Nevlozena karta"
Else 'karta SD je ve slotu
Locate 1 , 1
Lcd "Vlozena karta"
Uloz_data = "test;" + Str(s)
Uloz_data = Uloz_data + ";"
Incr S
Call Inc_sd()
Locate 2 , 1
Lcd Uloz_data
End If
Wait 5
Toggle Led
Loop
End
'xxxxxxxxxxxxxxxxxxxxxxxxxxx zapis na SD kartu xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Sub Inc_sd
Gbdriveerror = Driveinit() 'Inciace karty
If Gbdriveerror = 0 Then
Btemp1 = Initfilesystem(1) ' Partition 1
If Btemp1 <> 0 Then
Cls
Lcd "error: " ; Btemp1
Locate 2 , 1
Lcd "at Init f. system"
Wait 2
Else
Locate 1 , 6
Lcd "S"
Call Record_file(uloz_data)
Locate 1 , 6
Lcd " "
End If
Else
Print "Error during Drive Init: " ; Gbdriveerror
Cls
Lcd "Err Init:" ; Gbdriveerror
Wait 2
End If
End Sub
Sub Record_file(byval Uloz_data2 As String )
Reset Watchdog
Open "Teplota1.csv" For Append As #1
Write #1 , Uloz_data2 ' write is also supported
Flush #1
Close #1
Call Testerrors(1)
Reset Watchdog
Wait 1
Locate 2 , 6
Lcd "O"
Reset Watchdog
Wait 1
Locate 2 , 6
Lcd " "
Reset Watchdog
End Sub
'***************************************************************************
'* Debug routine, test AVR-DOS error flag. If errors found signals user
'* flashing a LED and writes the error position code
'***************************************************************************
Sub Testerrors(byval N As Byte )
While Gbdoserror <> 0
Cls
Lcd "err:" ; Gbdoserror ; " posit:" ; N
Waitms 100
Wend
End Sub
' xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx end SD karta xxxxxxxxxxxxxxxxxxxxxxxxxxx
0
Nemusím vedeť váhu elektrónu ak chcem zaspájkovať tranzistor.
-
- Podobné témy
- Odpovedí
- Zobrazení
- Posledný príspevok