Cześć wszystkim
Pisze w sprawie takiej ze postanowiłem połączyć atmege32 i kartę microSD 2 gb i tu sie pojawiaja problemy a mianowicie program nie pokazuje mi pojemnosci karty niby inicjacja przebiega ok ale cos nie tak nizej wstawiam kod programu
Prosze o pomoc w rozwiazaniu tego problemu poniewaz w bascom jestem mozna powiedziec "raczkujacy" jezeli chodzi o avr-dos i obsluge kart .
Dodam ze karte o pojemnosci 2 GB formatowalem systemem FAT nie FAT32
Serdecznie pozdrawiam Bartek
Pisze w sprawie takiej ze postanowiłem połączyć atmege32 i kartę microSD 2 gb i tu sie pojawiaja problemy a mianowicie program nie pokazuje mi pojemnosci karty niby inicjacja przebiega ok ale cos nie tak nizej wstawiam kod programu
$regfile = "m32def.dat"
$crystal = 8000000
$lib "Lcd-pcf8833.lbx " 'special color display support '8 MHz
Config Graphlcd = Color , Controlport = Portc , Cs = 3 , Rs = 2 , Scl = 0 , Sda = 1
Const Blue = &B00000011 'predefined contants are making programming easier
Const Yellow = &B11111100
Const Red = &B11100000
Const Green = &B00011100
Const Black = &B00000000
Const White = &B11111111
Const Brightgreen = &B00111110
Const Darkgreen = &B00010100
Const Darkred = &B10100000
Const Darkblue = &B00000010
Const Brightblue = &B00011111
Const Orange = &B11111000
Glcdcmd &H36 'Mem_control
Glcddata &H48 'My=0 Mx=0 V=1 Lao=1 Rbg=0 "00110000"
Glcdcmd &H21
Config Clock = Soft
Config Watchdog = 2048
Config Timer1 = Pwm , Pwm = 8 , Compare A Pwm = Clear Down , Compare B Pwm = Clear Down , Prescale = 1
Start Timer1
Pwm1a = 150
Cls
$include "CONFIG_AVR-DOS.Bas"
'$include "AVR-DOS.LBX"
'---SPI-HW----------------------------------------------------------------------
Const Cmmc_soft = 0 'SPI HARDWARE
' define Chip-Select Pin
Config Pinb.4 = Output ' define here Pin for CS of MMC/SD Card
Mmc_cs Alias Portb.4
Set Mmc_cs
' Define here SS Pin of HW-SPI of the CPU (f.e. Pinb.0 on M128)
Config Pinb.7 = Output ' define here Pin of SPI SS
Spi_ss Alias Portb.7
Set Spi_ss ' Set SPI-SS to Output and High por Proper work of
' SPI as Master
' HW-SPI is configured to highest Speed
Config Spi = Hard , Interrupt = Off , Data Order = Msb , Master = Yes , Polarity = High , Phase = 1 , Clockrate = 4 , Noss = 1 'Config Spi = Soft , Din = Pinb.3 , Dout = Portb.2 , Ss = Portb.0 , Clock = Portb.1
Spsr.0 = 1 ' Double speed on ATMega128
Spiinit ' Init SPI
'Spiinit
' Error
Const Cperrdrivereset = 225 ' Error response Byte at Reset command
Const Cperrdriveinit = 226 ' Error response Byte at Init Command
Const Cperrdrivereadcommand = 227 ' Error response Byte at Read Command
Const Cperrdrivewritecommand = 228 ' Error response Byte at Write Command
Const Cperrdrivereadresponse = 229 ' No Data response Byte from MMC at Read
Const Cperrdrivewriteresponse = 230 ' No Data response Byte from MMC at Write
Const Cperrdrive = 231
Const Cperrdrivenotsupported = 232 ' return code for DriveGetIdentity, not supported yet
Waitms 700
Dim Gbdriveerror As Byte ' General Driver Error register
Dim Gbdriveerrorreg As Byte ' Driver load Error-Register of HD in case of error
Dim Gbdrivestatusreg As Byte ' Driver load Status-Register of HD on case of error
Dim Gbdrivedebug As Byte
Dim B As Word
Dim C As Word
Dim Wolne As Long
Dim Rozmiar As Long
Dim S As String * 96
S = Dir()
$lib "MMC.LIB" ' link driver library
$external _mmc
Enable Interrupts
Box(0 , 0) -(130 , 130) , White
Gbdriveerror = Driveinit()
B = Initfilesystem(1)
C = Drivecheck()
'start watchdog
'Wolne = Diskfree()
'Rozmiar = Disksize()
Setfont Color8x8
Cls
Lcdat 10 , 10 , "Init - " ; B , Black , White
Wait 2
Lcdat 20 , 10 , "Stan - " ; C , Black , White
Wait 1
Lcdat , 30 , 10 , "Spraw. - " ; Gbdriveerror , Black , White
Wait 1
Lcdat , 40 , 10 , "Rozmiar - " ; Disksize() , Black , White
Wait 1
'Lcdat , 50 , 10 , "Wolne - " ; Diskfree() , Black , White
'Wait 1
Lcdat . 60 , 10 , "Katalog - " ; S ; Black , White
End
$include "color8x8.font"Prosze o pomoc w rozwiazaniu tego problemu poniewaz w bascom jestem mozna powiedziec "raczkujacy" jezeli chodzi o avr-dos i obsluge kart .
Dodam ze karte o pojemnosci 2 GB formatowalem systemem FAT nie FAT32
Serdecznie pozdrawiam Bartek